allow setting led color and brightness values, and display current values in status...
authorsimimeie <simimeie>
Wed, 30 Jun 2010 19:40:49 +0000 (19:40 +0000)
committersimimeie <simimeie>
Wed, 30 Jun 2010 19:40:49 +0000 (19:40 +0000)
console.c

index 140765cff33886754ed24d3397cdce2bc00159b4..87f20434bc2d8fcf998dd787dd49ed3ca98f0bf3 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1,4 +1,4 @@
-/* $Id: console.c,v 1.2 2010/06/26 19:08:18 simimeie Exp $
+/* $Id: console.c,v 1.3 2010/06/30 19:40:49 simimeie Exp $
  * Functions for a serial console.
  */
 
@@ -321,24 +321,44 @@ ISR(USART_RX_vect) {
                        console_printpgm_noirq_P(PSTR("Settings written to EEPROM."));*/
                } else if (strcmp_P(inputbuf, PSTR("status")) == 0) {
                        console_printpgm_noirq_P(PSTR("Current status:\r\n"));
-                       console_printpgm_noirq_P(PSTR("none. nothing implemented yet."));
+                       console_printpgm_noirq_P(PSTR("red = "));
+                       console_printhex8_noirq(ledpwm_re);
+                       console_printpgm_noirq_P(PSTR(", green = "));
+                       console_printhex8_noirq(ledpwm_gr);
+                       console_printpgm_noirq_P(PSTR(", blue = "));
+                       console_printhex8_noirq(ledpwm_bl);
+                       console_printpgm_noirq_P(PSTR(", brightness = "));
+                       console_printhex8_noirq(ledpwm_bri);
+                       /*console_printpgm_noirq_P(CRLF);*/
                } else if (strncmp_P(inputbuf, PSTR("r "), 2) == 0) {
                        uint8_t v;
                        v = strtoul(&inputbuf[2], NULL, 0);
-                       ledpwm_setled(LEDPWM_REDLED, v);
-                       console_printpgm_P(PSTR("brightness of RED LED set to 0x"));
+                       ledpwm_re = v;
+                       ledpwm_setled(LEDPWM_REDLED, (((uint16_t)ledpwm_re * ledpwm_bri) / 255));
+                       console_printpgm_P(PSTR("RED value set to 0x"));
                        console_printhex8(v);
                } else if (strncmp_P(inputbuf, PSTR("g "), 2) == 0) {
                        uint8_t v;
                        v = strtoul(&inputbuf[2], NULL, 0);
-                       ledpwm_setled(LEDPWM_GREENLED, v);
-                       console_printpgm_P(PSTR("brightness of GREEN LED set to 0x"));
+                       ledpwm_gr = v;
+                       ledpwm_setled(LEDPWM_GREENLED, (((uint16_t)ledpwm_gr * ledpwm_bri) / 255));
+                       console_printpgm_P(PSTR("GREEN value set to 0x"));
                        console_printhex8(v);
                } else if (strncmp_P(inputbuf, PSTR("b "), 2) == 0) {
                        uint8_t v;
                        v = strtoul(&inputbuf[2], NULL, 0);
-                       ledpwm_setled(LEDPWM_BLUELED, v);
-                       console_printpgm_P(PSTR("brightness of BLUE LED set to 0x"));
+                       ledpwm_bl = v;
+                       ledpwm_setled(LEDPWM_BLUELED, (((uint16_t)ledpwm_bl * ledpwm_bri) / 255));
+                       console_printpgm_P(PSTR("BLUE value set to 0x"));
+                       console_printhex8(v);
+               } else if (strncmp_P(inputbuf, PSTR("bri "), 2) == 0) {
+                       uint8_t v;
+                       v = strtoul(&inputbuf[4], NULL, 0);
+                       ledpwm_bri = v;
+                       ledpwm_setled(LEDPWM_REDLED, (((uint16_t)ledpwm_re * ledpwm_bri) / 255));
+                       ledpwm_setled(LEDPWM_GREENLED, (((uint16_t)ledpwm_gr * ledpwm_bri) / 255));
+                       ledpwm_setled(LEDPWM_BLUELED, (((uint16_t)ledpwm_bl * ledpwm_bri) / 255));
+                       console_printpgm_P(PSTR("brightness set to 0x"));
                        console_printhex8(v);
 #ifdef JOKECMDS
                } else if (strncmp_P(inputbuf, PSTR("ls"), 2) == 0) {
This page took 0.05292 seconds and 4 git commands to generate.