Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
WordClock.h@0:0f571ea154f8, 2017-11-05 (annotated)
- Committer:
- charly
- Date:
- Sun Nov 05 20:30:51 2017 +0000
- Revision:
- 0:0f571ea154f8
- Child:
- 1:dd9657c12de6
Class to display time in words with WS2812B LEDs
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| charly | 0:0f571ea154f8 | 1 | #ifndef WORDCLOCK_H | 
| charly | 0:0f571ea154f8 | 2 | #define WORDCLOCK_H | 
| charly | 0:0f571ea154f8 | 3 | |
| charly | 0:0f571ea154f8 | 4 | #include "mbed.h" | 
| charly | 0:0f571ea154f8 | 5 | #include "neopixel.h" | 
| charly | 0:0f571ea154f8 | 6 | |
| charly | 0:0f571ea154f8 | 7 | /** class to display Time on WS2812B-LED-Stripe | 
| charly | 0:0f571ea154f8 | 8 | * Drive LEDs with PixelArray | 
| charly | 0:0f571ea154f8 | 9 | * with 11x10 LED-Matrix and 4 minute-LEDS | 
| charly | 0:0f571ea154f8 | 10 | * | 
| charly | 0:0f571ea154f8 | 11 | * GERMAN LAYOUT !!!!!! | 
| charly | 0:0f571ea154f8 | 12 | * | 
| charly | 0:0f571ea154f8 | 13 | |
| charly | 0:0f571ea154f8 | 14 | ESKISTLFÜNF | 
| charly | 0:0f571ea154f8 | 15 | ZEHNZWANZIG | 
| charly | 0:0f571ea154f8 | 16 | DREIVIERTEL | 
| charly | 0:0f571ea154f8 | 17 | TGNACHVORJM | 
| charly | 0:0f571ea154f8 | 18 | HALBXZWÖLFP | 
| charly | 0:0f571ea154f8 | 19 | ZWEINSIEBEN | 
| charly | 0:0f571ea154f8 | 20 | KDREIRHFÜNF | 
| charly | 0:0f571ea154f8 | 21 | ELFNEUNVIER | 
| charly | 0:0f571ea154f8 | 22 | WACHTZEHNRS | 
| charly | 0:0f571ea154f8 | 23 | BSECHSFMUHR | 
| charly | 0:0f571ea154f8 | 24 | **** | 
| charly | 0:0f571ea154f8 | 25 | |
| charly | 0:0f571ea154f8 | 26 | */ | 
| charly | 0:0f571ea154f8 | 27 | |
| charly | 0:0f571ea154f8 | 28 | // Number of LEDS in Stripe | 
| charly | 0:0f571ea154f8 | 29 | #define NUMLEDS 114 | 
| charly | 0:0f571ea154f8 | 30 | |
| charly | 0:0f571ea154f8 | 31 | //Number of different words | 
| charly | 0:0f571ea154f8 | 32 | #define NUMWORDS 28 | 
| charly | 0:0f571ea154f8 | 33 | |
| charly | 0:0f571ea154f8 | 34 | /* Class: WorldClock | 
| charly | 0:0f571ea154f8 | 35 | * A class to show time in words with LED-Stripe | 
| charly | 0:0f571ea154f8 | 36 | */ | 
| charly | 0:0f571ea154f8 | 37 | class WordClock { | 
| charly | 0:0f571ea154f8 | 38 | |
| charly | 0:0f571ea154f8 | 39 | public: | 
| charly | 0:0f571ea154f8 | 40 | |
| charly | 0:0f571ea154f8 | 41 | /** Create a WordClock Object with WS2812B-LEDs connected to pin (must be a SPI-MOSI-pin) | 
| charly | 0:0f571ea154f8 | 42 | * | 
| charly | 0:0f571ea154f8 | 43 | * @param pin SPI-MOSI pin to connect LEDs | 
| charly | 0:0f571ea154f8 | 44 | */ | 
| charly | 0:0f571ea154f8 | 45 | WordClock (PinName pin); | 
| charly | 0:0f571ea154f8 | 46 | |
| charly | 0:0f571ea154f8 | 47 | /** display_time(hour, minute, second) | 
| charly | 0:0f571ea154f8 | 48 | * | 
| charly | 0:0f571ea154f8 | 49 | * @param time time to display | 
| charly | 0:0f571ea154f8 | 50 | * | 
| charly | 0:0f571ea154f8 | 51 | */ | 
| charly | 0:0f571ea154f8 | 52 | void display_time(int hour,int minute, int second = 0); | 
| charly | 0:0f571ea154f8 | 53 | |
| charly | 0:0f571ea154f8 | 54 | /** test_display(int option) | 
| charly | 0:0f571ea154f8 | 55 | * | 
| charly | 0:0f571ea154f8 | 56 | * @param option option for test | 
| charly | 0:0f571ea154f8 | 57 | * @param index index for test. Which LED/word to set. 0..NUMLEDS, 0..NUMWORDS | 
| charly | 0:0f571ea154f8 | 58 | * | 
| charly | 0:0f571ea154f8 | 59 | */ | 
| charly | 0:0f571ea154f8 | 60 | void test_display(int option, int index = 0); | 
| charly | 0:0f571ea154f8 | 61 | |
| charly | 0:0f571ea154f8 | 62 | /** Convert a color from the HSV representation to RGB. | 
| charly | 0:0f571ea154f8 | 63 | * | 
| charly | 0:0f571ea154f8 | 64 | * @param h hue 0.0 ... 1.0 | 
| charly | 0:0f571ea154f8 | 65 | * @param s saturation 0.0 ... 1.0 | 
| charly | 0:0f571ea154f8 | 66 | * @param v value 0.0 ... 1.0 | 
| charly | 0:0f571ea154f8 | 67 | */ | 
| charly | 0:0f571ea154f8 | 68 | neopixel::Pixel hsvToRgb(float h, float s, float v); | 
| charly | 0:0f571ea154f8 | 69 | |
| charly | 0:0f571ea154f8 | 70 | private : | 
| charly | 0:0f571ea154f8 | 71 | //clear ledstripe (without displaying) | 
| charly | 0:0f571ea154f8 | 72 | void cls(); | 
| charly | 0:0f571ea154f8 | 73 | |
| charly | 0:0f571ea154f8 | 74 | // all words | 
| charly | 0:0f571ea154f8 | 75 | void es_ist(); | 
| charly | 0:0f571ea154f8 | 76 | void fuenf_m(); | 
| charly | 0:0f571ea154f8 | 77 | void zehn_m(); | 
| charly | 0:0f571ea154f8 | 78 | void zwanzig(); | 
| charly | 0:0f571ea154f8 | 79 | void drei_m(); | 
| charly | 0:0f571ea154f8 | 80 | void vier_m(); | 
| charly | 0:0f571ea154f8 | 81 | void tel(); | 
| charly | 0:0f571ea154f8 | 82 | void nach(); | 
| charly | 0:0f571ea154f8 | 83 | void vor(); | 
| charly | 0:0f571ea154f8 | 84 | void halb(); | 
| charly | 0:0f571ea154f8 | 85 | void zwoelf(); | 
| charly | 0:0f571ea154f8 | 86 | void zwei(); | 
| charly | 0:0f571ea154f8 | 87 | void eins(); | 
| charly | 0:0f571ea154f8 | 88 | void ein(); | 
| charly | 0:0f571ea154f8 | 89 | void sieben(); | 
| charly | 0:0f571ea154f8 | 90 | void drei_h(); | 
| charly | 0:0f571ea154f8 | 91 | void fuenf_h(); | 
| charly | 0:0f571ea154f8 | 92 | void elf(); | 
| charly | 0:0f571ea154f8 | 93 | void neun(); | 
| charly | 0:0f571ea154f8 | 94 | void vier_h(); | 
| charly | 0:0f571ea154f8 | 95 | void acht(); | 
| charly | 0:0f571ea154f8 | 96 | void zehn_h(); | 
| charly | 0:0f571ea154f8 | 97 | void sechs(); | 
| charly | 0:0f571ea154f8 | 98 | void uhr(); | 
| charly | 0:0f571ea154f8 | 99 | void m1(int second = 59); | 
| charly | 0:0f571ea154f8 | 100 | void m2(int second = 59); | 
| charly | 0:0f571ea154f8 | 101 | void m3(int second = 59); | 
| charly | 0:0f571ea154f8 | 102 | void m4(int second = 59); | 
| charly | 0:0f571ea154f8 | 103 | |
| charly | 0:0f571ea154f8 | 104 | //Digitalin for Pulldown | 
| charly | 0:0f571ea154f8 | 105 | DigitalIn di_pin_; | 
| charly | 0:0f571ea154f8 | 106 | |
| charly | 0:0f571ea154f8 | 107 | // The pixel array control class. | 
| charly | 0:0f571ea154f8 | 108 | neopixel::PixelArray array_; | 
| charly | 0:0f571ea154f8 | 109 | |
| charly | 0:0f571ea154f8 | 110 | // the array of leds | 
| charly | 0:0f571ea154f8 | 111 | neopixel::Pixel ledstripe_[NUMLEDS]; | 
| charly | 0:0f571ea154f8 | 112 | |
| charly | 0:0f571ea154f8 | 113 | |
| charly | 0:0f571ea154f8 | 114 | //Hue-Value (HSV)for LEDS | 
| charly | 0:0f571ea154f8 | 115 | float hue_; | 
| charly | 0:0f571ea154f8 | 116 | |
| charly | 0:0f571ea154f8 | 117 | // Saturation (HSV)for LEDs | 
| charly | 0:0f571ea154f8 | 118 | float saturation_; | 
| charly | 0:0f571ea154f8 | 119 | |
| charly | 0:0f571ea154f8 | 120 | //brightness/value(HSV) for LEDS | 
| charly | 0:0f571ea154f8 | 121 | float value_; | 
| charly | 0:0f571ea154f8 | 122 | |
| charly | 0:0f571ea154f8 | 123 | }; | 
| charly | 0:0f571ea154f8 | 124 | |
| charly | 0:0f571ea154f8 | 125 | #endif |