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.
Dependencies: DigitDisplay mbed
Revision 0:f8d65945b096, committed 2014-09-07
- Comitter:
- mfiore
- Date:
- Sun Sep 07 05:30:25 2014 +0000
- Commit message:
- initial commit - looks good and supports 0-9, a-b, hyphen, and underscore
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DigitDisplay.lib Sun Sep 07 05:30:25 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DisplayManager/DisplayManager.cpp Sun Sep 07 05:30:25 2014 +0000
@@ -0,0 +1,149 @@
+#include "mbed.h"
+#include "DisplayManager.h"
+
+DisplayManager::DisplayManager(PinName clk, PinName dio) : display(NULL) {
+ display = new DigitDisplay(clk, dio);
+}
+
+DisplayManager::~DisplayManager() {
+ if (display) delete display;
+}
+
+uint8_t DisplayManager::convert(uint8_t value) {
+ switch (value) {
+ case '0':
+ return 0x3f;
+ case '1':
+ return 0x06;
+ case '2':
+ return 0x5b;
+ case '3':
+ return 0x4f;
+ case '4':
+ return 0x66;
+ case '5':
+ return 0x6d;
+ case '6':
+ return 0x7d;
+ case '7':
+ return 0x07;
+ case '8':
+ return 0x7f;
+ case '9':
+ return 0x6f;
+ case 'a':
+ case 'A':
+ return 0x77;
+ case 'b':
+ case 'B':
+ return 0x7c;
+ case 'c':
+ case 'C':
+ return 0x39;
+ case 'd':
+ case 'D':
+ return 0x5e;
+ case 'e':
+ case 'E':
+ return 0x79;
+ case 'f':
+ case 'F':
+ return 0x71;
+ case 'g':
+ case 'G':
+ return 0x3d;
+ case 'h':
+ case 'H':
+ return 0x76;
+ case 'i':
+ case 'I':
+ return 0x30;
+ case 'j':
+ case 'J':
+ return 0x1e;
+ case 'k':
+ case 'K':
+ return 0x76;
+ case 'l':
+ case 'L':
+ return 0x38;
+ case 'm':
+ case 'M':
+ return 0x15;
+ case 'n':
+ case 'N':
+ return 0x54;
+ case 'o':
+ case 'O':
+ return 0x3f;
+ case 'p':
+ case 'P':
+ return 0x73;
+ case 'q':
+ case 'Q':
+ return 0x67;
+ case 'r':
+ case 'R':
+ return 0x50;
+ case 's':
+ case 'S':
+ return 0x6d;
+ case 't':
+ case 'T':
+ return 0x78;
+ case 'u':
+ case 'U':
+ return 0x3e;
+ case 'v':
+ case 'V':
+ return 0x1c;
+ case 'w':
+ case 'W':
+ return 0x2a;
+ case 'x':
+ case 'X':
+ return 0x76;
+ case 'y':
+ case 'Y':
+ return 0x6E;
+ case 'z':
+ case 'Z':
+ return 0x5b;
+ case '-':
+ return 0x40;
+ case '_':
+ return 0x08;
+
+ default:
+ return 0x00;
+ }
+}
+
+void DisplayManager::showMessage(char* message, int len) {
+ int shifts = 0;
+ char* cur = &message[0];
+ char* back = &message[len - 1];
+ uint8_t buf[4] = { 0x00, 0x00, 0x00, 0x00 };
+
+ while (shifts <= len + 4) {
+ buf[0] = buf[1];
+ buf[1] = buf[2];
+ buf[2] = buf[3];
+ if (cur == back) {
+ buf[3] = 0x00;
+ } else {
+ buf[3] = convert(*cur);
+ cur++;
+ }
+
+ shifts++;
+ display->writeRaw(buf);
+ wait(0.5);
+ }
+
+ wait(1);
+}
+
+void DisplayManager::clear() {
+ display->clear();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DisplayManager/DisplayManager.h Sun Sep 07 05:30:25 2014 +0000
@@ -0,0 +1,20 @@
+#ifndef DISPLAY_MANAGER_H
+#define DISPLAY_MANAGER_H
+
+#include "mbed.h"
+#include "DigitDisplay.h"
+
+class DisplayManager {
+ public:
+ DisplayManager(PinName clk, PinName dio);
+ ~DisplayManager();
+
+ void showMessage(char* message, int len);
+ void clear();
+
+ private:
+ uint8_t convert(uint8_t value);
+ DigitDisplay* display;
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Sep 07 05:30:25 2014 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "DisplayManager.h"
+
+using namespace std;
+
+int main() {
+ // use connector D3 on the sensor shield board
+ DisplayManager display(D3, D4);
+ //DigitDisplay display(D3, D4);
+
+ display.clear();
+ char chars[] = "jon and mike are cool dudes";
+
+ while (true) {
+ display.showMessage(chars, sizeof(chars));
+ /*
+ display.writeRaw(0, 0x01);
+ wait(5);
+ display.writeRaw(0, 0x02);
+ wait(5);
+ display.writeRaw(0, 0x04);
+ wait(5);
+ display.writeRaw(0, 0x08);
+ wait(5);
+ display.writeRaw(0, 0x10);
+ wait(5);
+ display.writeRaw(0, 0x20);
+ wait(5);
+ display.writeRaw(0, 0x40);
+ wait(5);
+ */
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Sep 07 05:30:25 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file