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.
LED7segmDual4094.h
00001 /* This library lets to use a led display made of at most 8 segments as a screen buffer device. Like this one: https://www.dropbox.com/s/a3rvqahxhvpj0w3/general.jpg?dl=0 00002 The dispaly has to be made of two shift registers - i used 4094 and they are guaranteed to work, but others may also without any change to the code. The 8 digits limit can be easily overcomed daisy-chaining more shift registers. Have in mind though that it will cause the dispaly to be dimmer. 00003 This library lets you treat the display as a screen buffer device i.e. each digit is a byte-sized and bits are ordered as usual ABCDEFG scheme goes. Object has a field fb, which is the size you have it initialized. 00004 Size 4 by default. So just write to object.fb[n] whatever you want. You can do all sorts of bitwise operations. And then you have to take care of calling the draw() method periodcaly to update the display. (preffered way: use systick or timer). 00005 There is also provided function to convert most ASCII characters to bitmasked segments: digitORascii2char. It also allows to toggle a dot. Hope you like it. 00006 There is a bonus feature: you can arrange the common cathodes/anodes in any way in the shift registers, because you can initialise the library with given order of them. 00007 The same with segments. (in progress). Moreover there can be different layout of segments between each digit (also not done). Whoa! 00008 */ 00009 #include "mbed.h" 00010 00011 #ifndef LED7segmDual4094_h 00012 #define LED7segmDual4094_h 00013 00014 class LED7segmDual4094{ 00015 private: 00016 char _numOfSegments; 00017 unsigned int *_anodesBitMask; 00018 unsigned int _segmentsBitMask; 00019 bool _anodesActiveState; 00020 DigitalOut _data; 00021 DigitalOut _clock; 00022 DigitalOut _strobe; 00023 void send4094(unsigned short _load); 00024 public: 00025 LED7segmDual4094(PinName data, PinName clock, PinName strobe, char numOfSegments = 4); 00026 char *fb; 00027 void draw(); 00028 void setAnodesBitMask(unsigned int *tab); 00029 void setAnodesActiveState(bool state); 00030 // void draw(char *tab); 00031 unsigned short load; 00032 //char i; 00033 char whichSegmMux; 00034 signed char digitORascii2char(char input, bool dot=0); 00035 // signed char return7seg; 00036 00037 }; 00038 00039 #endif
Generated on Tue Jul 12 2022 17:45:04 by
1.7.2