Numworks Epsilon  1.4.1
Graphing Calculator Operating System
led.cpp
Go to the documentation of this file.
1 #include "command.h"
2 #include <ion.h>
3 #include <ion/src/device/led.h>
4 
5 namespace Ion {
6 namespace Device {
7 namespace Bench {
8 namespace Command {
9 
10 // Input must be of the form "0xAABBCC" or "ON" or "OFF"
11 void LED(const char * input) {
12  if (strcmp(input, sON) == 0) {
15  return;
16  }
17  if (strcmp(input, sOFF) == 0) {
20  return;
21  }
22  if (input == nullptr || input[0] != '0' || input[1] != 'x' || !isHex(input[2]) ||!isHex(input[3]) || !isHex(input[4]) || !isHex(input[5]) || !isHex(input[6]) || !isHex(input[7]) || input[8] != NULL) {
24  return;
25  }
26  uint32_t hexColor = hexNumber(input+2);
27  KDColor ledColor = KDColor::RGB24(hexColor);
28  Ion::LED::setColor(ledColor);
30 }
31 
32 }
33 }
34 }
35 }
void shutdown()
Definition: led.cpp:25
void init()
Definition: led.cpp:20
const char *const sOK
Definition: command.cpp:9
const char *const sSyntaxError
Definition: command.cpp:11
const char *const sON
Definition: command.cpp:12
void writeLine(const char *line)
Definition: console_line.cpp:9
const char *const sOFF
Definition: command.cpp:13
unsigned int uint32_t
Definition: stdint.h:6
#define NULL
Definition: stddef.h:4
void LED(const char *input)
Definition: led.cpp:11
uint32_t hexNumber(const char *s, int maxLength)
Definition: command.cpp:33
void setColor(KDColor c)
Definition: led.cpp:8
Definition: color.h:6
int strcmp(const char *s1, const char *s2)
Definition: strcmp.c:3
Definition: backlight.h:6
static constexpr KDColor RGB24(uint32_t rgb)
Definition: color.h:13