From 29f09200a00a84abb95fea652c2ae0acd0dbab5a Mon Sep 17 00:00:00 2001 From: Frater Date: Fri, 9 Oct 2020 20:55:39 +0200 Subject: [PATCH] Update LED.MD --- LED.MD | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/LED.MD b/LED.MD index fde8ab8..41e1a54 100644 --- a/LED.MD +++ b/LED.MD @@ -1,21 +1,49 @@ -LED +All LEDs are in fact 2 LED (one red and one green) and seems to be connected to separated pins from the controller, or at least can be addressed by the controller following this addresses design: -All LEDs are in fact 2 LED (one red and one green) and seems to be connected to separated pins from the controller, or at least addressed by the controller like this - -LED 1 (r) = 1 +``` +LED 1 (r) = 1 LED 1 (g) = 2 - -LED 2 (r) = 3 +``` +``` +LED 2 (r) = 3 LED 2 (g) = 4 - -LED 3 (r) = 5 +``` +``` +LED 3 (r) = 5 LED 3 (g) = 6 +``` - - - -the commands to address the LED status is 0x1B 0x4C _status_ - -Status byte was divided in two part 4 high bits define the LED id, and 4 low bits define +There is no zero LED + +the commands to address the LED status is 0x1B 0x4C _STATUS_ + +_STATUS_ byte is divided in two parts: + 4 high bits are used to define the LED id, + 1 low bit is used to define the status (on/off) + +So Led's can controlled with the following (pseudo-c) code: +``` +#define LED_STATUS_ON 0x01 +#define LED_STATUS_OFF 0x00 + +#define LED_1_RED 0x10 +#define LED_1_GREEN 0x20 +#define LED_2_RED 0x30 +#define LED_2_GREEN 0x40 +#define LED_3_RED 0x50 +#define LED_3_GREEN 0x60 + +void SetLed(unsigned char ledid,unsigned char status) +{ + unsigned char cmd[3]; + + cmd[0] = "\x1b"; + cmd[1] = "\x4c"; + cmd[2] = (unsigned char) (ledid + status); + + SerialPtr_writebuffer(cmd,3); +} +SetLed(LED_1_GREEN, LED_STATUS_ON); +``` \ No newline at end of file