c

Raspberry PI with HD44780 LCD and I2C Interface Board

Sven Bachmann
After buying an HD44780 compatible LCD together with an I2C interface board (which has an PCF8574T soldered on it) I tried to output some text in C on it but the display just stayed black - or after changing some GPIOs, it stayed blue. I measured every pin of the PCF8574T and got the following scheme: PCF8574T <-> HD44780 P0 -- RS P1 -- R/W P2 -- EN P4 -- DB4 P5 -- DB5 P6 -- DB6 P7 -- DB7 R/W should be mapped to GND if the HD44780 should not talk back to the CPU.

Embedded Lua-Script into C

Sven Bachmann
This weekend, I played around a bit with Lua and C. My aim was to understand the Lua basics, embed the script engine into C and be able to even call a C function from Lua. With Google and a lot of documentation spread around the web this was a fairly easy task. The result are 2 short files. First file is the C-code main.c which initializes Lua, registers the C-function which will be later called by Lua and then executes the Lua-script.

Coding C: Warning: [...] is COMMON symbol

Sven Bachmann
Hi, if you’re writing a kernel module and get the following error: *** Warning: "symbol_name" [/path/to/module] is COMMON symbol Than its possible that you simply forgot to mark it as static. Thanks for this fix goes to Brad Aisa from the website KernelTrap. Bye, Sven

Coding C: initialize structs in definition

Sven Bachmann
Hi, Task We have a included struct called counter and we don’t want to assign the initial values in the main function. Solution source.c #include <counters.h> struct counter_t counter = { .max_value = 1234, }; int main(void) { return(0); } Bye, Sven

Coding C: put timestamp into your project

Sven Bachmann
Hi there, Task We have a Makefile, we have a C file, now we want update a timestamp whenever the C file is compiled. Solution Makefile CFLAGS += -D__TIMESTAMP__=\""$(shell date +%Y/%m/%d\ %H:%M:%S)"\" source.c include <stdio.h> #ifndef __TIMESTAMP__ #define __TIMESTAMP__ "NO TIMESTAMP DEFINED" #endif /* __TIMESTAMP__ */ int main(void) { printf("my tool (TS: %s)\n", __TIMESTAMP__); return(0); } Output ~$ ./source my tool (TS: 2008/11/06 09:55:22) Bye, Sven