Date: 2/14/2016
I tried alterations to the sample code until I got the flip-dot display to act more predictably.
Below is my revised code for the display with a little extra to automatically count up columns and rows:
/* Simple Serial ECHO script : Written by ScottC 04/07/2012 */
/* Stage 2 : Delimiters */
/* Adapted for LinkSprite V3 and AlfaZeta flip-dot display */
/* by Michael Shaub 2016 */
/* Use a variable called byteRead to temporarily store
the data coming from the computer */
//refresh all panels
//0x80 0x82 0x8F
int frameDelay = 250; //pause 400 ms between frames being sent to the board
int counter = 0;
int rowCounter = 0;
int row1 = 0; //hold variable for row1
int row2 = 0; //hold variable for row2
int row3 = 0; //hold variable for row3
int row4 = 0; //hold variable for row4
int row5 = 0; //hold variable for row5
int row6 = 0; //hold variable for row6
int row7 = 0; //hold variable for row7
String rowString = "B1101010";
int rowArray[ ] = {0,0,0,0,0,0,0};
void setup() {
// Turn the Serial Protocol ON
Serial.begin(57600);
}
void loop() {
//header, Command, Address, Data, End Character (0xFF address = ALL BOARDS)
if(counter > 7){
counter = 0;
rowCounter++;
}
if(rowCounter > 7) rowCounter = 0;
byte test_allWhite[]= {128, 136, 255, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x8F};
byte test_allBlack[]= {128, 136, 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8F};
byte refresh_all[]= {0x80, 0x82, 0x8F};
//Serial.write(test_1, 116);
//Serial.write(test_allWhite, 116);
//Serial.write(test_1, 116);
//Serial.write(refresh_all, 116);
//row3 = byte(B1111010);
for(int j=0; j<8; j++){ //set values to match counter, should flip dots one by one across
if(j == counter){
rowArray[j] = 1; //set to 1
}else{
rowArray[j] = 0; //reset value to 0
}
}
/*
if(counter == 1){
rowArray[0] = 1;
}
if(counter == 2){
rowArray[0] = 0;
rowArray[1] = 1;
}
if(counter == 3){
rowArray[1] = 0;
rowArray[2] = 1;
}
*/
row1 = 0;
row2 = 0;
row3 = 0;
row4 = 0;
row5 = 0;
row6 = 0;
row7 = 0;
for(int i=0; i<8; i++){
int a = rowArray[i];
int b = a << i; //bitshift the value the number of positions equal to the digit
switch(rowCounter){
case 1:
row1 = row1 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 2:
row2 = row2 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 3:
row3 = row3 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 4:
row4 = row4 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 5:
row5 = row5 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 6:
row6 = row6 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
case 7:
row7 = row7 | b; //bitwise OR addition of the "b" value to the existing "row3" value
break;
}
}
byte test_2[]= {0x80, 0x87, 0xFF, row1, row2, row3, row4, row5, row6, row7, 0x8F};
Serial.write(test_2, 116);
//Serial.write(test_1, 116);
//Serial.write(refresh_all, 116);
delay(frameDelay); // wait for a second
counter++;
/*
row1 = counter;
row2 = counter;
row3 = counter;
row4 = counter;
row5 = counter;
row6 = counter;
row7 = counter;
*/
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.