Can't display anything on 16x2 display(I2C Board) with nodemcu? - esp8266

I'm trying to display text on 16x2 display using a Nodemcu board. I have connected the display using a serial connector to board like below.
Vcc => 3v Pin
GND => G pin
SCL => D1 pin
SDA => D2 pin
This is the code I have tried
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello world");
lcd.setCursor(1,0);
lcd.print("ESP32 I2C LCD");
}
void loop() {}
I was able to compile this code successfully and save it to the board using Arduino IDE, but nothing display on the screen, the backlights are working fine.
Does anyone know what is going on?
the example I followed https://www.instructables.com/id/Interface-LCD-Using-NodeMCU/

Try to change
lcd.backlight();
to
lcd.setBacklight((uint8_t)1);

Related

How to display an image without decorations

Can't find an option for Imagemagick's display command to avoid decorations. Just need to show the image, is there any way to achieve this, or any other "core" command that can do it?
I'm assuming you mean to display images without window decorations. There's many many ways to achieve this, but I would like to point-out that your OS/desktop-manager probably has something that you can leverage.
For example, on my mac, I can use open & qlmanage to show images with minimal decorations.
# Use OS defaults
open wizard.png
# or Quicklook
qlmanage -p wizard.png
YMMV. There's also great alternatives listed to this question.
ImageMagick's display utility has the options -immutable, -backdrop, & -window options to interact with X11 display system. If you don't mind X11's tile bar, then -immutable will hide the additional display widgets.
display -immutable -resize 40% wizard.png
However, if you absolutely do not want any window decoration, then you may need to role your own solution. The -window option will set the image as a background to a running window. Knowning this, I just need to create a borderless-window & capture an ID to pass to identify. See this answer for creating a window w/o any decoration.
// simple_window (compile with `gcc -L/usr/X11R6/lib -lX11 -o simple_window simple_window.c')
#include <stdio.h>
#include <X11/Xlib.h>
int main(int argc, const char * argv[]) {
Display * root;
Window win;
int screen;
root = XOpenDisplay(NULL);
screen = DefaultScreen(root);
win = XCreateSimpleWindow(root,
RootWindow(root, screen),
10, 10,
400, 600,
0,
BlackPixel(root, screen),
WhitePixel(root, screen));
Atom win_type = XInternAtom(root, "_NET_WM_WINDOW_TYPE", False);
long value = XInternAtom(root, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(root,
win,
win_type,
4, 32,
PropModeReplace,
(unsigned char *) &value, 1);
XMapWindow(root, win);
printf("Window created %lu\n", win);
XEvent e;
while(1) {
XNextEvent(root, &e);
if (e.type == KeyPress) {
break;
}
}
XCloseDisplay(root);
return 0;
}
Compiling the above program & running will print out the current window id; which, I can now pass the import utility to write the image as a background.
A bit hack-ish, but again, YMMV.

Windows IoT - Zebra Bluetooth Printer

I have two Zebra Bluetooth Printers, a MZ220 and iMZ220. The "only" thing I would do, is to print text with a Windows IoT System on a Raspberry Pi 2. Nothing more ;)
Example:
Line1 " Hello World"
Line2 "---------------"
Line3 "Date:01.01.2016"
Line4 "Time: 18:00"
The USB Bluetooth Adapter BTA-403 from ORICO, I guess works well. With the Explorer I can connect to the Printer. But, what next? How do I connect to the Printer? How do I say to the Printer print "Hello World!"
Thanks!
These printers are using Bluetooth like a serial port aka SSP profile.
First, you'll have to edit your app manifest and add a new device capability
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="bluetooth.rfcomm">
<Device Id="any">
<Function Type="name:serialPort"/>
</Device>
</DeviceCapability>
</Capabilities>
You can get the paired printers like this
var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
Once you identified the right printer, you can open the connection
var service = await RfcommDeviceService.FromIdAsync(DeviceInfo.Id);
var socket = new StreamSocket();
await socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
You should be able to send then information like this
private async void PrintAsync(string line)
{
var writer = new DataWriter(socket.OutputStream);
var command = "^XA^LH30,30^F020,10^AD^FD + line + "^FS^XZ";
writer.WriteString(command);
await writer.StoreAsync();
}

Dart:io stdin raw character codes

I've created a Dart console app and need to process keycodes like Arrow keys and function keys from stdin? The samples I've seen are typically String based :
Stream readLine() => stdin.transform(UTF8.decoder).transform(new LineSplitter());
readLine().listen(processLine);
I modified the above sample hoping to get the raw ints like this:
Stream readInts() => stdin;
readInts().listen(processInts);
void processInts(List<int> kbinput) {
for (int i=0;i<kbinput.length;i++){
print ("kbinput:${kbinput[i]}");
}
}
It seems stdin provides only printable characters and not all ascii keycodes. If it is not possible from stdin, can I create & load a stream within my native extension with the keycodes? How can my console app get to the ascii keycodes of any keypress? Thanks for your help!
One way would be
import 'dart:io' as io;
import 'dart:convert' show UTF8;
void main() {
io.stdin.echoMode = false;
var input;
while(input != 32) { // leave program with [Space][Enter]
input = io.stdin.readByteSync();
if(input != 10) print(input); // ignore [Enter]
}
io.stdin.echoMode = true;
}
but it only returns a value after Enter is pressed.
For one key press it returns from one up to three bytes.
It seems it's not easy to get a keystroke from console without pressing Enter
see Capture characters from standard input without waiting for enter to be pressed for more details.
You could create a native extension that implements the suggested solution in the linked question.

Linux device driver stepper motor

hi i am new to Device driver, i am writing code to driver a stepper motor using ioctl...my code goes this way
while(is_transmit_empty() ==0);
outb(0x99, SERIAL_PORT_BASE);
printk("data sent\n");
mdelay(500);
while(is_transmit_empty() ==0);
outb(0xCC, SERIAL_PORT_BASE);
printk("data sent\n");
mdelay(500);
while(is_transmit_empty() ==0);
outb(0x66, SERIAL_PORT_BASE);
printk("data sent\n");
mdelay(500);
while(is_transmit_empty() ==0);
outb(0x33, SERIAL_PORT_BASE);
printk("data sent\n");
mdelay(500);
and my
define CLOCKWISE _IO(MAGIC_NO, 0 )...
with this code my stepper motor rotates only one step even though its in a loop for 50 for rotating 360-deg......
tell me where am i going wrong with my code .....

BlackBerry 8900 - issues in full touch screen mode with two pushScreen()

This issue appears on BB 9800 when the device/emulator is in full touch mode (closed slider).
I don't know if the issue appears on other TS devices (I have only this device).
I have the MainScreen (MS) object (where almost entire application is working here), and some "dialogs" (D1, D2) for displaying some details, which both extend FullScreen, and I display them with UiApplication.getUiApplication().pushScreen(this), and I close them with UiApplication.getUiApplication().popScreen(this);
D1 - some details
D2 - an EditField for adding some comments
If I push only one "dialog" MS -> D1 or MS -> D2 all things are ok.
if I push 2 "dialogs" MS -> D1-> D2, if I press on virtual keyboard, there are some visual mess (like no painting areas), only the first pressed key is taken from VirtualKeyboard (into edit); if I dissmiss this D2 (with popScreen()), the D1 has visual issues (again, like no painting areas)...
D1:
public class DialogBase extends FullScreen
{
public DialogBase()
{
super(new VerticalFieldManager(), Field.NON_FOCUSABLE);
. . .
}
. . .
public void open()
{
UiApplication.getUiApplication().pushScreen(this);
}
public void closeAndExit()
{
UiApplication.getUiApplication().popScreen(this);
}
}
D2 is very similar to D1 (the same constructor + open + close)
Do you have an ideea?
Thank you,
Tibi.

Resources