Class to display Time in words on WS2812B-LED-Stripe. * Drive LEDs with PixelArray * with 11x10 LED-Matrix and 4 minute-LEDS * GERMAN LAYOUT !!!!!!
WordClock.h
00001 #ifndef WORDCLOCK_H 00002 #define WORDCLOCK_H 00003 00004 #include "mbed.h" 00005 #include "neopixel.h" 00006 00007 /** class to display Time on WS2812B-LED-Stripe 00008 * Drive LEDs with PixelArray 00009 * with 11x10 LED-Matrix and 4 minute-LEDS 00010 * 00011 * GERMAN LAYOUT !!!!!! 00012 * 00013 00014 ESKISTLFÜNF 00015 ZEHNZWANZIG 00016 DREIVIERTEL 00017 TGNACHVORJM 00018 HALBXZWÖLFP 00019 ZWEINSIEBEN 00020 KDREIRHFÜNF 00021 ELFNEUNVIER 00022 WACHTZEHNRS 00023 BSECHSFMUHR 00024 **** 00025 00026 */ 00027 00028 // Number of LEDS in Stripe 00029 #define NUMLEDS 114 00030 00031 //Number of different words 00032 #define NUMWORDS 28 00033 00034 /** Class: WorldClock 00035 * A class to show time in words with LED-Stripe 00036 */ 00037 class WordClock { 00038 00039 public: 00040 00041 /** Create a WordClock Object with WS2812B-LEDs connected to pin (must be a SPI-MOSI-pin) 00042 * 00043 * @param pin SPI-MOSI pin to connect LEDs 00044 */ 00045 WordClock (PinName pin); 00046 00047 /** display_time(hour, minute, second) 00048 * 00049 * @param time time to display 00050 * 00051 */ 00052 void display_time(int hour,int minute, int second = 0); 00053 00054 /** test_display(int option) 00055 * 00056 * @param option option for test 00057 * 1 color gradient from red to red through hsv colors. 00058 * 2 display one LED in White, full brightness. 00059 * 3 display a word. 00060 * @param index index for test. Which LED/word to set. 0..NUMLEDS, 0..NUMWORDS 00061 * 00062 */ 00063 void test_display(int option, int index = 0); 00064 00065 /** Convert a color from the HSV representation to RGB. 00066 * 00067 * @param h hue 0.0 ... 1.0 00068 * @param s saturation 0.0 ... 1.0 00069 * @param v value 0.0 ... 1.0 00070 */ 00071 neopixel::Pixel hsvToRgb(float h, float s, float v); 00072 00073 private : 00074 //clear ledstripe (without displaying) 00075 void cls(); 00076 00077 // all words 00078 void es_ist(); 00079 void fuenf_m(); 00080 void zehn_m(); 00081 void zwanzig(); 00082 void drei_m(); 00083 void vier_m(); 00084 void tel(); 00085 void nach(); 00086 void vor(); 00087 void halb(); 00088 void zwoelf(); 00089 void zwei(); 00090 void eins(); 00091 void ein(); 00092 void sieben(); 00093 void drei_h(); 00094 void fuenf_h(); 00095 void elf(); 00096 void neun(); 00097 void vier_h(); 00098 void acht(); 00099 void zehn_h(); 00100 void sechs(); 00101 void uhr(); 00102 void m1(int second = 59); 00103 void m2(int second = 59); 00104 void m3(int second = 59); 00105 void m4(int second = 59); 00106 00107 public: 00108 /** display SZ for Sommerzeit 00109 */ 00110 void sz(); //Sommerzeit 00111 /** display WZ for Winterzeit 00112 */ 00113 void wz(); //Winterzeit 00114 private: 00115 00116 //Digitalin for Pulldown 00117 DigitalIn di_pin_; 00118 00119 // The pixel array control class. 00120 neopixel::PixelArray array_; 00121 00122 // the array of leds 00123 neopixel::Pixel ledstripe_[NUMLEDS]; 00124 00125 00126 //Hue-Value (HSV)for LEDS 00127 float hue_; 00128 00129 // Saturation (HSV)for LEDs 00130 float saturation_; 00131 00132 //brightness/value(HSV) for LEDS 00133 float value_; 00134 00135 }; 00136 00137 #endif
Generated on Mon Jul 18 2022 19:16:40 by
1.7.2