Skip to content
Browse files

first commit

  • Loading branch information...
1 parent 95af75d commit 0f726268bab6de01ce068c521bd9faf2c315145f @ellensundh committed
Showing with 135 additions and 0 deletions.
  1. +80 −0 BockiMessageBoard.cpp
  2. +52 −0 BockiMessageBoard.h
  3. +3 −0 keywords.txt
View
80 BockiMessageBoard.cpp
@@ -0,0 +1,80 @@
+/*
+ BockiMessageBoard.cpp -
+ Created by Ellen Sundh, April 12, 2012.
+ Released into the public domain.
+*/
+
+#include "Arduino.h"
+#include <math.h>
+#include "BockiMessageBoard.h"
+
+//char BockiMessageBoard::ports[] =
+BockiMessageBoard::BockiMessageBoard(int boardId)
+{
+ Serial.begin(9600);
+ ports = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ String bId = String(boardId);
+ pId = "A";
+ dTime = "WA";
+ dModeIn = "FE";
+ dModeOut = "FE";
+ if(bId.length() == 1) bId = "0" + bId;
+ messageBoardId = "<ID" + bId + ">";
+ updateConfigureString();
+}
+/* Configures how long the message should who, how to animate in and out. Produces codes according to settings. */
+void BockiMessageBoard::configure(int displayTime, String displayModeIn, String displayModeOut)
+{
+
+ displayTime = int(fmin(abs(displayTime),25));
+ Serial.print(displayTime);
+ dTime = "W" + String(ports[round(displayTime)]);
+
+ dModeIn = displayModeIn;
+ dModeOut = displayModeOut;
+
+ updateConfigureString();
+
+}
+
+/* Sets the latest configuration passed to the library */
+
+void BockiMessageBoard::updateConfigureString() {
+ configureString = "<L1><P" + pId + "><" + dModeIn + "><MA><" + dTime + "><" + dModeOut + ">";
+}
+
+/* Returns the latest configuration to be calculated in the checksum */
+
+String BockiMessageBoard::returnConfigureString(String inputString) {
+ updateConfigureString();
+ return configureString + inputString;
+}
+/*
+displayMessage calculates the checksum of display message and configuration of the message board.
+Prints out the message to message board.
+*/
+void BockiMessageBoard::displayMessage(int pageId, String inputString)
+{
+ byte checksum = 0x00;
+ //pId = pageId;
+
+
+ inputString = returnConfigureString(inputString);
+
+ char ascii_char[inputString.length() + 1];
+ inputString.toCharArray(ascii_char, sizeof(ascii_char));
+
+
+ for (int i=0; i<strlen(ascii_char); i++) {
+ checksum = checksum ^ ascii_char[i];
+
+ }
+ String hexStr = String(checksum, HEX);
+ hexStr.toUpperCase();
+ if(hexStr.length() == 1) {
+ hexStr = "0" + hexStr;
+ }
+ inputString = inputString + hexStr;
+ Serial.println(messageBoardId + inputString + "<E>");
+}
+
View
52 BockiMessageBoard.h
@@ -0,0 +1,52 @@
+/*
+ BockiMessageBoard.h -
+ Created by Ellen Sundh, April 15, 2012.
+ Released into the public domain.
+*/
+
+#ifndef BockiMessageBoard_h
+#define BockiMessageBoard_h
+
+#include "Arduino.h"
+
+#define IMMEDIATE "FA"
+#define CURTAINUP "FC"
+#define CURTAINDOWN "FD"
+#define SCROLLLEFT "FE"
+#define SCROLLRIGHT "FF"
+#define VERTICALOPEN "FG"
+#define VERTICALCLOSE "FH"
+#define SCROLLUP "FI"
+#define SCROLLDOWN "FJ"
+#define HOLD "FK"
+#define SNOW "FL"
+#define TWINKLE "FM"
+#define BLOCKMOVE "FN"
+#define RANDOM "FP"
+
+typedef enum MessageBoardPage {PAGE_A, PAGE_B, PAGE_C, PAGE_D, PAGE_E, PAGE_F, PAGE_G, PAGE_H, PAGE_I, PAGE_J, PAGE_K, PAGE_L, PAGE_M, PAGE_N, PAGE_O, PAGE_P, PAGE_Q, PAGE_R, PAGE_S, PAGE_T, PAGE_U, PAGE_V, PAGE_W, PAGE_X, PAGE_Y, PAGE_Z};
+
+
+class BockiMessageBoard
+{
+ public:
+ BockiMessageBoard(int);
+ void configure(int, String, String);
+ void displayMessage(int, String);
+
+
+ private:
+ void updateConfigureString();
+ String returnConfigureString(String);
+ String messageBoardId;
+ String configureString;
+ String pId;
+ String dTime;
+ String dModeIn;
+ String dModeOut;
+ String ports;
+
+};
+
+#endif
+
View
3 keywords.txt
@@ -0,0 +1,3 @@
+BockiAscii KEYWORD1
+displayMessage KEYWORD2
+configure KEYWORD2

0 comments on commit 0f72626

Please sign in to comment.
Something went wrong with that request. Please try again.