-
Notifications
You must be signed in to change notification settings - Fork 13
lib_w1209: Use display, keys, relay, and probe on W1209 board.
The W1209 is sold as a thermostat board with three LED digits, a relay, a temperature probe, and three push buttons. They are very inexpensive; two dollars is a common price. If three LED digits and buttons are enough, it is convenient to have them on the same board as the CPU.
You can find my test/example program in my stm8_test section. The wiki for test_w1209 is here: W1209 test/example
The header file lib_w1209.h has three configuration items you can change if you wish.
#define KB_SIZE 4 /* size of key buffer */
#define KB_DEBOUNCE 40 /* debounce count in milliseconds */
#define LED_UPDATE 5 /* milliseconds between LED updates */
The value of 5 milliseconds between LED updates means that each LED will be on for 5 milliseconds and off for 10. This gives better than 60 herz. I tried 7 and that looked okay, and 10 was too slow.
Like my other LED libraries, you get simple xxx_putc(), xxx_puts(), and xxx_getc() functions that use ASCII characters. The LEDs will display the numeric digits, the letters "ABCDEFHIJLOPSU", the space, and the characters "-_[]". The keys return '0', '1', and '2'.
The setup function w12_init() sets up the whole board, since there is not much you can change.
void w12_init(void); /* initialize the board */
void w12_putc(char); /* Write digit/char to LED (use bit-7 for decimal point) */
void w12_puts(char *); /* Write string to LED (insert decimal point where desired.) */
void w12_curs(char); /* Set cursor position */
void w12_blink(char); /* Set LED blinking, Blink rate * 1/100 second or 0 (disable) */
char w12_getc(void); /* Get keypress, zero or ASCII key ('0' to '2'), bit-7 set if released */
void w12_poll(void); /* Poll for display, keys, and blinking (call every millisecond) */
void w12_relay(char); /* Turn the relay on/off, zero = off, non-zero = on */
short w12_probe(void); /* Get the current temperature probe value (raw) */
The polling function is super easy, just use the callback provided by lib_clock.
int main() {
/* stuff */
w12_init();
clock_init(clock_ms, clock_10);
/* stuff */
}
void clock_ms(void)
{
w12_poll();
}
You may contact me at [email protected] and I am available for embedded projects.