I’ll have to think about the results but that things almost work w/the Beta Arduino release says buffer overruns are real and are the root cause of the line4 (and some other?) problems. As to the line1 & 2 oddness … any chance there was some scrolling going on ? Even scrolling doesn’t explain everything. But I am sure it’s due to some setup issue.
Can you explain, in detail, what you did and what "bugged out" looks like ?Belial88:
24A/24a, but 24 flashes super fast, so it’s like nothing displays at all there (just a/A).24B/24b, again the flashing number
24C/24c normal operation i presume
24D/24d normal operation i presume.
so… the new beta is better but still doesn’t work, seeing as we got 2 fully working lines instead of 1. Doesn’t seem as FUBAR’d as the other time i guess…
I tried to see if I could just do exactly what I originally wanted and get away (cpu temp via software/gpu temp via softwware, had to use some random voltage since gpu not plugged in atm/volt1/volt2) and first 2 lines just were bugged out ;/
Here’s some thoughts for you. The code that puts the received btye count doesn’t know one line from another, so that code can’t be the cause of line1&2 “bugging out”. That said, if you haven’t already, go back to the un-hacked code and fill all lines w/characters, 20/line, and make sure lines 3&4 get totally filled. One thing to look for is any difference in how lines 1&2 are setup vs lines 3&4. That the byte count appears so breify on lines 1&2 tells me the following sequence MUST be happening.
-Snartie sends a cursor position command
-hacked code prints the byte count at that position, cursor advances 2 columns automatically
-either the desired character is displayed (lines 3&4) or some other “clear line” command is given and then the desired character is displayed. Does line1 look like 24A or 24a with the 24 gone real quick or like 24A – A (A at the line start) ? That is do the A and a stay at the 3’rd column ? (a Utube vid would be mega useful) If they stay in col3 the some other command is being sent before that line’s character, and only for lines 1&2. That would screwup our test code but that’s OK. It’s only test code and we’ve learned what we needed from it (that Smartie sends a whole line).
The overrun fix really should make your Micro act just like an Uno. The rest is just some Smartie setup oddness that others seem to have figured a way around. I’ve yet to figure out how to stop/start screen changes. :?
Does the simulated LCD on your PC act normally ?
Its 24a/24A and other flashing events being xxA/xxa.
I’ll upload a video tonight. The simulated lcd always works fine (i dont use cpu emulation, as it is at default, it just seems to make the font change).
would it be easier to use UART or something? I need to use usb for power (the usb battery pack) but i could maybe still send data other ways. My z87 also has a com serial port (look at bottom by internal usb 2.0 heasers on z87x-ud3h)
I tend to think it won't (or shouldn't) make a difference at this point (w/buffer overruns fixed). The same commands and data will come over the UART link as does over the USB, just slower.Belial88:
would it be easier to use UART or something?
I’ll guess that mobo serial port is RS-232 levels as well. You’ll need a RS->TTL serial converter to make the correct signals for the Micro. If you want to try, I’ll direct the code to listen to the Micro’s serial pins. I believe that to be a trivial task.
So the A and a are always in column 3, where they should be given the test code. It's just the extra byte count that blinks into/outof view so quickly (lines1&2 only). And yet using 'normal' code you can't display CPU usage or temp or even just 1234567890 w/o the first 2 chars being "bugged out" ? I await the video.Belial88:
Its 24a/24A and other flashing events being xxA/xxa.
Also make a copy of your Smartie config.ini file, call it config.txt and attach it to a post.
I looked at some other documents and I’m sure of how Smartie is supposed to talk to the Micro using Orbital Matrix protocol. It’s just what I thought it was having examined the Smartie Arduino code. I still wonder what Smartie@the PC end is actually sending (to cause line1@2 oddness). So I created another test code that examines each burst of commands and data from the PC and displays the results on lines 3&4 of the LCD. Those results are how many cursor position commands (expect 3-4), home many home cmds (expect 0-1), how many clear cmds (expect 0-1) and how many miscellaneous cmds (expect 0). It’ll also display the number of bytes sent in last burst (expect 80-100) and time btw bursts (= refresh time ?).
It waits until 100 msec after the last burst and does the line 3&4 stuff. So if there’s no refreshing, it should display the results for burst #1, w/a funky time (= time since Arduino reset). Manual or forced refreshes should show correct data but time is limited to 5 places for display so don’t take more than 99.999 secs.
I recommend emptying all lines on all screens and then (to start) put just an A on line1. Refresh time set to 500 msec. From our prior testing all I expect is one update on the LCD. I think that’s goofy given the refresh time but what are we to do ? Then I would put an a on line1, screen 2 w/only those 2 screens enabled, w/a 1 sec screen display time. That should cause an updating LCD (IIRC). After that see what you can dream up that would tell us what Smartie@PC is/isn’t doing. Obviously anything you put on lines3&4 will be overwritten after 100 msec. The {, }, [ and ] still work to display the A0 and A1 voltages.
cr= # of cursor position cmds
hm= # of cursor home cmds
cl= # of clear commands
ms= # of misc (not expected to be used) cmds
latest test code
#include <VarSpeedServo.h> //variable speed servo library
#include <LiquidCrystal.h>
//declare the constants to be used
#define LEDPIN 13 //pin attached to LED
#define servoPIN 9 //Servo control line
#define SWitchPIN 2 //input from N.O. momentary switch
#define redPIN 11 //PWM pin for red LED backlight
#define greenPIN 10 //PWM pin for green LED backlight
#define bluePIN 12 //PWM pin for blue LED backlight
#define rsPIN 8 //reset pin for LCD
#define enablePIN 7 //enable pin for LCD
#define d4PIN 4 //data pin4 for LCD
#define d5PIN 5 //data pin5 for LCD
#define d6PIN 6 //data pin6 for LCD
#define d7PIN 3 //data pin7 for LCD
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
#define posOpenCMD 1900 //Define Clockwise Servo position in usec
#define posCloseCMD 600 //Define CounterClockwise Servo position in usec
#define DBdelay 2000 //Min time needed btw any 2 button presses, in msec
#define fastSPD 100 //speed setting; 1 = slowest, 255 is fastest (???)
#define slowSPD 15 //Speed Servo/Door opens and closes (15 is good average)
#define DIV_1 1.0 //gain correction for A0 channel
#define DIV_2 1.0 //note it's 1.0, not 1, to get full floating point accuracy
#define V_REF 2.54 //use the measured Aref voltage
//declare the variables used
volatile boolean doorOPEN = false; //desired door state set to closed
byte rxbyte = 0; //rxbyte is the received byte from Smartie
byte temp = 0;
volatile unsigned long SWtime = 0; //holds the time of the last valid switch push
float voltage1 = 0.0; // calculated voltage for A0
float voltage2 = 0.0; // calculated voltage for A1
//test variables, not part of final program
unsigned long int_time = 0;
int b_ctr = 0; //count of bytes in last burst
int home_ctr = 0; //count of lcd home cmds in last burst
int misc_ctr = 0; //count of miscellaneous lcd cmds in last burst
int cur_ctr = 0; //count of lcd cursor position cmds in last burst
int clr_ctr = 0; //count of lcd clear cmds in last burst
LiquidCrystal lcd(rsPIN, enablePIN, d4PIN, d5PIN, d6PIN, d7PIN);
VarSpeedServo myServo; //create a servo object
void setup() {
//set the pins to be ins or outs
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW); //turn LED off
pinMode(servoPIN, OUTPUT);
pinMode(SWitchPIN, INPUT_PULLUP);
pinMode(redPIN, OUTPUT);
pinMode(greenPIN, OUTPUT);
pinMode(bluePIN, OUTPUT);
attachInterrupt(1, SW_ISR, FALLING);
Serial.begin(9600);
lcd.begin(numCols, numRows);
lcd.clear();
analogWrite(bluePIN,0); //Blue brightness 255-0
analogWrite(redPIN,255); //Red brightness 255-0
analogWrite(greenPIN,255); //Green brightness 255-0
analogReference(INTERNAL); //use the internal 2.56v ADC reference
//CMD the servo to close the door
myServo.attach(servoPIN); // Attach the servo
myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position
//put a hello world on the LCD
lcd.home();
lcd.print("Line 1");
lcd.setCursor(10, 1);
lcd.print("Line 2");
lcd.setCursor(20, 2);
lcd.print("Line 3");
lcd.setCursor(30, 3);
lcd.print("Line 4");
delay(2000);
}
//the following function is the ISR that responds to the push button switch
//it commands the door to open or close at slow speed
void SW_ISR(){
//debounce the switch by ignoring any interrupt that occurs too soon after the prior one
unsigned long Time = millis();
if(Time - SWtime > DBdelay){ //enough time has elapsed, not a switch bounce
SWtime = Time; //save new time of switch push
doorOPEN = !doorOPEN; //reverse desired door state
if(doorOPEN == true){
digitalWrite(LEDPIN, HIGH); //turn LED on
myServo.slowmove(posOpenCMD, slowSPD); //tell servo to go to open position
}
else {
digitalWrite(LEDPIN, LOW); //turn LED off
myServo.slowmove(posCloseCMD, slowSPD); //tell servo to go to closed position
}
}
}
//this function is used by the smartie code to get data from the PC
byte serial_getch(){
int incoming;
while (Serial.available()==0){
//check to see if data burst is done
if((millis() - int_time > 100) && (b_ctr > 0)){
//print last message burst results on LCD
counters();
}
}
// read the incoming byte:
incoming = Serial.read();
int_time = millis();
b_ctr++;
return (byte) (incoming &0xff);
}
//this test function displays various test info on LCD lines 3&4
void counters(){
//move to row 3 and print counters
lcd.setCursor(0, 2);
lcd.print("cr=");
lcd.print(cur_ctr);
lcd.setCursor(5, 2);
lcd.print("hm=");
lcd.print(home_ctr);
lcd.setCursor(10, 2);
lcd.print("cl=");
lcd.print(clr_ctr);
lcd.setCursor(15, 2);
lcd.print("ms=");
lcd.print(misc_ctr);
//move to row 4 and print counter and refresh time
lcd.setCursor(0, 3);
lcd.print("byte= ");
lcd.print(b_ctr);
lcd.setCursor(10, 3);
lcd.print("time ");
lcd.print(int_time);
cur_ctr = 0;
home_ctr = 0;
misc_ctr = 0;
clr_ctr = 0;
b_ctr = 0;
}
//the main loop is now just the hacked version of the Arduino Smartie code
void loop(){
rxbyte = serial_getch(); //this calls the 'function' serial_getch(), stores result in rxbyte
if (rxbyte == 254) //Matrix uses 254 for commands, if rxbyte = 254 the the code below runs
{
switch (serial_getch()) //calls serial_getch() to get the next byte from the PC
{
case 66: //former backlight on command
break;
case 70: //former backlight off command
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
cur_ctr++;
break;
case 72: //cursor home (reset display position)
lcd.command(2);
home_ctr++;
break;
case 74: //show underline cursor
lcd.command(0b00001110);
misc_ctr++;
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
misc_ctr++;
break;
case 76: //move cursor left
lcd.command(16);
misc_ctr++;
break;
case 77: //move cursor right
lcd.command(20);
misc_ctr++;
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.print(serial_getch()); //get each pattern byte
}
misc_ctr++;
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
misc_ctr++;
break;
case 86: //GPO OFF
//implement later
misc_ctr++;
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
misc_ctr++;
break;
case 88: //clear display, cursor home
lcd.command(1);
clr_ctr++;
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
misc_ctr++;
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
misc_ctr++;
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
misc_ctr++;
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/
case 0x5B: //Formerly [, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x5D: //Formerly ], now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7B: //Formerly left brace, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7D: //Formerly right brace, now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd
}
Just a note on what I think “should” be happening before I forget it.
After the LCD has been initialized it should be ready for commands and character data to be displayed. I’d expect Smartie@PC to send a burst of commands and data at the refresh rate.
With an Uno, or like MCU at the receiving end, the bytes are sent about 1 byte/msec (9600 baud) because they must get into the MCU via USB->serial translator IC and then into a serial port UART. A command takes 2-4 bytes and a character just 1. When the Arduino receives either it takes about 325 usec to send it to the LCD via those 4 data lines and clock line. That leaves, for an Uno, about 2/3’rds of an msec before the next byte is received. And because an Uno has no* buffer on it’s UART, it has to be ready or that byte might get dropped and lost. So timing is critical on an Uno based Smartie system.
On your Micro there’s a real USB - USB link, so the bytes come in at least 4x faster, and maybe a lot faster. The Arduino code for your USB link is supposed to implement a 64 byte buffer. So as the bytes come in at some high rate, they get stored in the buffer. The Arduino Smartie code takes a byte out, at a slower rate, perhaps only every 325 usecs. The result is that if enough commands and data are sent fast enough you can have a full buffer and then the byte(s) get dropped and lost. The fix in the Beta software was to have the Arduino tell the PC “my buffer is full, hold the bytes until I am ready”. Same concept as a UART using software flow control. This fix apparently works, as line4 data, presumably at the end of a burst, is no longer being lost.
And yet lines 1&2 are still ‘whacked’ somehow. So I’m left wondering if, becase the Micro can pull commands from the buffer so quickly, that perhaps it’s sending one command that needed that 2/3’rds of an msec that an Uno provided but is no longer there in your case. Perhaps that command is used for lines 1&2 and not 3&4, because when Smartie was expanded from 16x2 to 20x4, the coder saw some redundant code wasn’t needed ??? Got me.
In any case it might be helpful to have an idea of what commands are being used, hence the new test code.
And 1 more idea for a fix might be to add back in a 1 msec delay after sending an LCD command, to get back to Uno-like timing.
As to why Smartie doesn’t always refresh at the supposed refresh time … ??? I’ll be curious to see the times via the test code. Seems to that when I put CPU usage on line1, and it shows in the simulated LCD, it should also show in the real LCD. Seemingly it does for other people.
Save your Smartie config.ini file for each test case that you decide has worth. It’ll be useful in correlating commands vs what the LCD is supposed to look like.
*to be strict, there’s a 1 byte buffer that holds the received byte while the next byte is coming in. That’s of limited use.
I just think that this whole thing is on the edge too much to work reliably.
First of all, I’m more familiar with AVR stuff than Arduino libraries.
I don’t see how they are using a 6 wire interface.
Are they never reading from the LCD?
To get optimal timing you need to read the busy flag.
What are they doing, running delay based on expected timings?
Also, wiring up 4 more wires gets you an 8 bit interface.
The ADC sampling is occurring in the main loop.
You are locking out the LCD processing during this time.
How long does the sampling take?
Wouldn’t it be better to run it continuously and interrupt on done?
I still think that using the “Smartie” as the formatting template is a bad idea.
I think only raw data should be going over the USB,
Perhaps but it's not clear to me what the problem is. The unmodified Arduino Smartie code seems to suffer from whatever it is afflicting lines 1&2 (I would like to see it, pics worth a 1000 words). According to the WWW others have made Smartie work with Arduino on a 32U4 MCU. I do wonder how they didn't have a buffer problem. Then again perhaps the 'recent' Beta release brought in some new bugs. It really is simple enough that I can't grok how/where it's screwing up. And that bugs me. This ain't rocket science.Renate:
I just think that this whole thing is on the edge too much to work reliably.
IIRC the 6 wires are a strobe, enable and 4 data lines. The R/w line is HW'ed for write. My guess is they are using delays, which is why the LCD library runs so slowly. But speed isn't an issue (or shouldn't be) given the data is buffered.Renate:
First of all, I’m more familiar with AVR stuff than Arduino libraries.I don’t see how they are using a 6 wire interface.
Are they never reading from the LCD?
To get optimal timing you need to read the busy flag.
What are they doing, running delay based on expected timings?
Also, wiring up 4 more wires gets you an 8 bit interface.
Actually the ADC code only runs when triggered from a Smartie command. It should run to completion, displaying all it's data, before the code fetches the next byte from the USB ring buffer. The conversion is about 125 usec, the 'FP' math another 100 perhaps and then the library code has to format 5 chars and write them and a decimal pt, add 20 and 6*325 usec. Total might be 2.2 msec. So what ? All that's happening during that time is bytes being added into the buffer. They'll get processed in a few more msecs. Afterall what's the end result ? A human readable display. Since the data has to persist long enough to be understood, speed isn't a prime concern.Renate:
The ADC sampling is occurring in the main loop.You are locking out the LCD processing during this time.
How long does the sampling take?
Wouldn’t it be better to run it continuously and interrupt on done?
Perhaps, Smartie has a lot of front end data collection capability. What would be a major improvement would be a better tailend plugin. Instead of having an Arduino translate Matrix LCD commands into LCD library commands, the plugin could send the data and formatting commands. That said all the scrolling and fancy screen-to-screen transitioning is done and working (supposedly). Perhaps the simplest thing would be to have Smartie do its thing but the plugin just sends an 80 byte packet of ASCII characters at every refresh cycle. Add a sensible header and trailer to the data ... let the Arduino write each data byte to the display in order. Then again that'll eliminate underlines and blinking and other effects native to the LCD controller ???Renate:
I still think that using the “Smartie” as the formatting template is a bad idea.I think only raw data should be going over the USB,
If you wanted to code up such a plugin and the Arduino end to match it, I’m sure nobody would complain.
I managed to beg/borrow/steal a Micro so give me a day to confirm (or disprove) the theories espoused so far. I’ll also be able to time what Smartie@PC sends.
I looked at some other documents and I’m sure of how Smartie is supposed to talk to the Micro using Orbital Matrix protocol. It’s just what I thought it was having examined the Smartie Arduino code. I still wonder what Smartie@the PC end is actually sending (to cause line1@2 oddness). So I created another test code that examines each burst of commands and data from the PC and displays the results on lines 3&4 of the LCD. Those results are how many cursor position commands (expect 3-4), home many home cmds (expect 0-1), how many clear cmds (expect 0-1) and how many miscellaneous cmds (expect 0). It’ll also display the number of bytes sent in last burst (expect 80-100) and time btw bursts (= refresh time ?).
cr=1 hm=0 cl=0, ms=04
byte= 241 time XXXXX (started at like 60000 and just goes up… 140000, 150000, 190000…)
when doing A/a only.
What should I take video of exactly?
I mean other people using micro might only be using static values, or they aren’t having much text on the lcd when they use anything dynamic like changing values or multiple screens. Maybe they use stuff like 16x2 or smaller displays too.
Anyways, doing this code, with A/B/C/D and a/b/c/d on 2 screens, 500/500 refresh and all.
#include <VarSpeedServo.h> //variable speed servo library
#include <LiquidCrystal.h>
//declare the constants to be used
#define LEDPIN 13 //pin attached to LED
#define servoPIN 9 //Servo control line
#define SWitchPIN 2 //input from N.O. momentary switch
#define redPIN 11 //PWM pin for red LED backlight
#define greenPIN 10 //PWM pin for green LED backlight
#define bluePIN 12 //PWM pin for blue LED backlight
#define rsPIN 8 //reset pin for LCD
#define enablePIN 7 //enable pin for LCD
#define d4PIN 4 //data pin4 for LCD
#define d5PIN 5 //data pin5 for LCD
#define d6PIN 6 //data pin6 for LCD
#define d7PIN 3 //data pin7 for LCD
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
#define posOpenCMD 1900 //Define Clockwise Servo position in usec
#define posCloseCMD 600 //Define CounterClockwise Servo position in usec
#define DBdelay 2000 //Min time needed btw any 2 button presses, in msec
#define fastSPD 100 //speed setting; 1 = slowest, 255 is fastest (???)
#define slowSPD 15 //Speed Servo/Door opens and closes (15 is good average)
#define DIV_1 1.0 //gain correction for A0 channel
#define DIV_2 1.0 //note it's 1.0, not 1, to get full floating point accuracy
#define V_REF 2.54 //use the measured Aref voltage
//declare the variables used
volatile boolean doorOPEN = false; //desired door state set to closed
byte rxbyte = 0; //rxbyte is the received byte from Smartie
byte temp = 0;
volatile unsigned long SWtime = 0; //holds the time of the last valid switch push
float voltage1 = 0.0; // calculated voltage for A0
float voltage2 = 0.0; // calculated voltage for A1
int bctr = 0;
LiquidCrystal lcd(rsPIN, enablePIN, d4PIN, d5PIN, d6PIN, d7PIN);
VarSpeedServo myServo; //create a servo object
void setup() {
//set the pins to be ins or outs
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW); //turn LED off
pinMode(servoPIN, OUTPUT);
pinMode(SWitchPIN, INPUT_PULLUP);
pinMode(redPIN, OUTPUT);
pinMode(greenPIN, OUTPUT);
pinMode(bluePIN, OUTPUT);
attachInterrupt(1, SW_ISR, FALLING);
Serial.begin(9600);
lcd.begin(numCols, numRows);
lcd.clear();
analogWrite(bluePIN,0); //Blue brightness 255-0
analogWrite(redPIN,255); //Red brightness 255-0
analogWrite(greenPIN,255); //Green brightness 255-0
analogReference(INTERNAL); //use the internal 2.56v ADC reference
//CMD the servo to close the door
myServo.attach(servoPIN); // Attach the servo
myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position
//put a hello world on the LCD
lcd.home();
lcd.print("Line 1");
lcd.setCursor(10, 1);
lcd.print("Line 2");
lcd.setCursor(20, 2);
lcd.print("Line 3");
lcd.setCursor(30, 3);
lcd.print("Line 4");
}
//the following function is the ISR that responds to the push button switch
//it commands the door to open or close at slow speed
void SW_ISR(){
//debounce the switch by ignoring any interrupt that occurs too soon after the prior one
unsigned long Time = millis();
if(Time - SWtime > DBdelay){ //enough time has elapsed, not a switch bounce
SWtime = Time; //save new time of switch push
doorOPEN = !doorOPEN; //reverse desired door state
if(doorOPEN == true){
digitalWrite(LEDPIN, HIGH); //turn LED on
myServo.slowmove(posOpenCMD, slowSPD); //tell servo to go to open position
}
else {
digitalWrite(LEDPIN, LOW); //turn LED off
myServo.slowmove(posCloseCMD, slowSPD); //tell servo to go to closed position
}
}
}
//this function is used by the smartie code to get data from the PC
byte serial_getch(){
int incoming;
while (Serial.available()==0){
}
// read the incoming byte:
incoming = Serial.read();
bctr++ ;
return (byte) (incoming &0xff);
}
//the main loop is now just the hacked version of the Arduino Smartie code
void loop(){
rxbyte = serial_getch(); //this calls the 'function' serial_getch(), stores result in rxbyte
if (rxbyte == 254) //Matrix uses 254 for commands, if rxbyte = 254 the the code below runs
{
switch (serial_getch()) //calls serial_getch() to get the next byte from the PC
{
case 66: //former backlight on command
break;
case 70: //former backlight off command
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
lcd.print(bctr); //display byte count for prior line
bctr = 0;
break;
case 72: //cursor home (reset display position)
lcd.command(2);
lcd.print(bctr); //display byte count for prior line
bctr = 0;
break;
case 74: //show underline cursor
lcd.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
break;
case 76: //move cursor left
lcd.command(16);
break;
case 77: //move cursor right
lcd.command(20);
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.print(serial_getch()); //get each pattern byte
}
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
break;
case 88: //clear display, cursor home
lcd.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/
case 0x5B: //Formerly [, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x5D: //Formerly ], now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7B: //Formerly left brace, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7D: //Formerly right brace, now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd
}
Someone is working on an HWInfo plugin for lcd smartie so that should make my earlier bitching about cpu and gpu temps not being able to be shown without having to run coretemp, and same plugin cant show both, and cant show other info that’s useful, etc.
Thanks a lot meenmac for your help, if I just got a different MCU would this all work? Or is this fixable? Didnt you recommend the micro in the first place
My initial results, using just one or 2 simple screens, shows Smartie (@ the PC end) acting normally. That is it’s send messages whose content looks proper given how I setup the Smartie GUI. I’ve yet to measuring the timing of messages directly but indirectly that seems OK too.
What I did (since I don’t have an LCD) was to replace the Arduino Smartie code w/code that stored all the data sent over the USB, byte by byte, and then later send that data back over the USB so I could look at it all. Thus I could ‘decode’ the commands and data sent by Smartie @PC. I started with a simple setup; 1 screen enabled, displaying just a on line1, b on line2, c on line3 and d on line4. I’d have the Micro running and then startup Smartie. I’d wait various times and then close Smartie. I’d then retrieve the saved data.
What I found was that the results were the same every time. Smartie goes through an LCD startup process (details in attached file) where it turns off fancy cursors, clears the screen and some other miscellaneous stuff that shouldn’t affect you as those commands are ignored. It then does a 1 time write to each line, starting w/line1, of the character for that line followed by 19 spaces. Then it waits until Smartie is closed. Smartie then does a shutdown procedure; writing 20 spaces to each line and doing some more misc stuff. So static lines get sent once and never updated, despite a refresh time = 500 msec, something we’d already figured out.
Next I changed (only) line2 from a b to a dynamic CPU usage. I repeated the same process. I saw the same startup and shutdown processes. I saw a, b, c d going to lines1-4 just once (like before). I then saw line2 (only) being updated with differing numbers (CPU usage) at some rate that seemed about right. IOW Smartie was updating line2 as expected.
Lastly I enabled another screen with a 2 sec display time and A, B, C, D on lines1-4. Screen #1 was left as above, a 1 sec display time, 500 msec refresh. This time I saw what I expected at first but I never saw the whole 2’nd screen. I saw the A and B, being updated apparently (A, B, A, B then screen 1 stuff), but never saw commands to get C or D on lines3-4. Screen 1 commands looked OK. So this needs some more looking into.
Here’s the annotated data from the 1’st two tests above.
Let's zero in on the last test above as my (limited) buffer never caught lines3-4 of screen #2 being commanded. So 2 screens enabled, screen 1 'time to show' = 1 sec, screen 2 'time to show' = 2 sec, refresh interval = 500 msec, no scrolling or other fancy stuff and no transition enabled (= none).Belial88:
What should I take video of exactly?
Screen 1
line1 = a
line2 = $CPUUsage%
line3 = c
line4 = b
Screen 2
line1 = A
line2 = B
line3 = C
line4 = D
Here’s my Smartie config.ini file. I note my “Screen 2” is really Screen 13 (only 1 and 13 are enabled).
Let’s see if C, D show up on your vid. Also any other video where lines1-2 are bugged out. Use the normal, unhacked Smartie code for these.
Turns out the test above ‘works’, prior apparent error was OE. I didn’t have lines3-4 set to C, D. When I do it all looks good.
So to do anything useful I need to see your config.ini and a vid of the LCD when it’s “bugged out”. So far as I can see, Smartie is doing what we’ve come to expect, at least for simple test cases.
I also measured the line to line timing for the aforementioned test cases. All is as expected.
So if Smartie is causing some ‘bugging out’, it’s not because Smartie is doing something truly awful.
Mee_n_Mac:
Let's zero in on the last test above as my (limited) buffer never caught lines3-4 of screen #2 being commanded. So 2 screens enabled, screen 1 'time to show' = 1 sec, screen 2 'time to show' = 2 sec, refresh interval = 500 msec, no scrolling or other fancy stuff and no transition enabled (= none).Belial88:
What should I take video of exactly?Screen 1
line1 = a
line2 = $CPUUsage%
line3 = c
line4 = b
Screen 2
line1 = A
line2 = B
line3 = C
line4 = D
Here’s my Smartie config.ini file. I note my “Screen 2” is really Screen 13 (only 1 and 13 are enabled).
[attachment=0]config - Copy.txt[/attachment]Let’s see if C, D show up on your vid. Also any other video where lines1-2 are bugged out. Use the normal, unhacked Smartie code for these.
Sorry, I’m a bit confused. You mean use the plain smartie code from like the beginning that I quoted, or the code you last listed? You say test interchangeably to refer to the smartie GUI setup and the code (or i am mistaking it as such). Which of these?:
// include the library code:
#include <LiquidCrystal.h>
#define REDLITE 12
#define GREENLITE 11
#define BLUELITE 10
int brightness = 50;
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,3,4,5,6,7);
// RS, RW, Enable, 4,5,6,7 (Refer to the back of your LCD for details)
void setup() {
Serial.begin(9600);
// set up the LCD's number of rows and columns:
lcd.begin(numRows, numCols);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("**LCD SMARTIE**");
lcd.setCursor(0,1);
lcd.print("on Arduino");
lcd.setCursor(0,2);
lcd.print("*<3*");
lcd.setCursor(0,3);
lcd.print("Jeri");
pinMode(REDLITE, OUTPUT);
pinMode(GREENLITE, OUTPUT);
pinMode(BLUELITE, OUTPUT);
brightness = 50;
}
byte serial_getch(){
int incoming;
while (Serial.available()==0){}
// read the incoming byte:
incoming = Serial.read();
return (byte) (incoming &0xff);
}
void loop(){
byte rxbyte;
byte temp;
rxbyte = serial_getch();
if (rxbyte == 254) //Matrix Orbital uses 254 prefix for commands
{
switch (serial_getch())
{
case 66: //backlight on (at previously set brightness)
// not implemented
break;
case 70: //backlight off
// not implemented
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
break;
case 72: //cursor home (reset display position)
lcd.command(2);
break;
case 74: //show underline cursor
lcd.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
break;
case 76: //move cursor left
lcd.command(16);
break;
case 77: //move cursor right
lcd.command(20);
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.print(serial_getch()); //get each pattern byte
}
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
break;
case 88: //clear display, cursor home
lcd.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/ case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/ case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/ case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd
}
#include <VarSpeedServo.h> //variable speed servo library
#include <LiquidCrystal.h>
//declare the constants to be used
#define LEDPIN 13 //pin attached to LED
#define servoPIN 9 //Servo control line
#define SWitchPIN 2 //input from N.O. momentary switch
#define redPIN 12 //PWM pin for red LED backlight
#define greenPIN 11 //PWM pin for green LED backlight
#define bluePIN 10 //PWM pin for blue LED backlight
#define rsPIN 8 //reset pin for LCD
#define enablePIN 3 //enable pin for LCD
#define d4PIN 4 //data pin4 for LCD
#define d5PIN 5 //data pin5 for LCD
#define d6PIN 6 //data pin6 for LCD
#define d7PIN 7 //data pin7 for LCD
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
#define posOpenCMD 1900 //Define Clockwise Servo position in usec
#define posCloseCMD 600 //Define CounterClockwise Servo position in usec
#define DBdelay 2000 //Min time needed btw any 2 button presses, in msec
#define fastSPD 100 //speed setting; 1 = slowest, 255 is fastest (???)
#define slowSPD 15 //Speed Servo/Door opens and closes (15 is good average)
#define DIV_1 1.0 //gain correction for A0 channel
#define DIV_2 1.0 //note it's 1.0, not 1, to get full floating point accuracy
#define V_REF 2.54 //use the measured Aref voltage
//declare the variables used
volatile boolean doorOPEN = false; //desired door state set to closed
byte rxbyte = 0; //rxbyte is the received byte from Smartie
byte temp = 0;
volatile unsigned long SWtime = 0; //holds the time of the last valid switch push
float voltage1 = 0.0; // calculated voltage for A0
float voltage2 = 0.0; // calculated voltage for A1
//test variables, not part of final program
unsigned long int_time = 0;
int b_ctr = 0; //count of bytes in last burst
int home_ctr = 0; //count of lcd home cmds in last burst
int misc_ctr = 0; //count of miscellaneous lcd cmds in last burst
int cur_ctr = 0; //count of lcd cursor position cmds in last burst
int clr_ctr = 0; //count of lcd clear cmds in last burst
LiquidCrystal lcd(rsPIN, enablePIN, d4PIN, d5PIN, d6PIN, d7PIN);
VarSpeedServo myServo; //create a servo object
void setup() {
//set the pins to be ins or outs
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW); //turn LED off
pinMode(servoPIN, OUTPUT);
pinMode(SWitchPIN, INPUT_PULLUP);
pinMode(redPIN, OUTPUT);
pinMode(greenPIN, OUTPUT);
pinMode(bluePIN, OUTPUT);
attachInterrupt(1, SW_ISR, FALLING);
Serial.begin(9600);
lcd.begin(numCols, numRows);
lcd.clear();
analogWrite(bluePIN,0); //Blue brightness 255-0
analogWrite(redPIN,255); //Red brightness 255-0
analogWrite(greenPIN,255); //Green brightness 255-0
analogReference(INTERNAL); //use the internal 2.56v ADC reference
//CMD the servo to close the door
myServo.attach(servoPIN); // Attach the servo
myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position
//put a hello world on the LCD
lcd.home();
lcd.print("Line 1");
lcd.setCursor(0, 1);
lcd.print("Line 2");
lcd.setCursor(0, 2);
lcd.print("Line 3");
lcd.setCursor(0, 3);
lcd.print("Line 4");
delay(2000);
}
//the following function is the ISR that responds to the push button switch
//it commands the door to open or close at slow speed
void SW_ISR(){
//debounce the switch by ignoring any interrupt that occurs too soon after the prior one
unsigned long Time = millis();
if(Time - SWtime > DBdelay){ //enough time has elapsed, not a switch bounce
SWtime = Time; //save new time of switch push
doorOPEN = !doorOPEN; //reverse desired door state
if(doorOPEN == true){
digitalWrite(LEDPIN, HIGH); //turn LED on
myServo.slowmove(posOpenCMD, slowSPD); //tell servo to go to open position
}
else {
digitalWrite(LEDPIN, LOW); //turn LED off
myServo.slowmove(posCloseCMD, slowSPD); //tell servo to go to closed position
}
}
}
//this function is used by the smartie code to get data from the PC
byte serial_getch(){
int incoming;
while (Serial.available()==0){
//check to see if data burst is done
if((millis() - int_time > 100) && (b_ctr > 0)){
//print last message burst results on LCD
counters();
}
}
// read the incoming byte:
incoming = Serial.read();
int_time = millis();
b_ctr++;
return (byte) (incoming &0xff);
}
//this test function displays various test info on LCD lines 3&4
void counters(){
//move to row 3 and print counters
lcd.setCursor(0, 2);
lcd.print("cr=");
lcd.print(cur_ctr);
lcd.setCursor(5, 2);
lcd.print("hm=");
lcd.print(home_ctr);
lcd.setCursor(10, 2);
lcd.print("cl=");
lcd.print(clr_ctr);
lcd.setCursor(15, 2);
lcd.print("ms=");
lcd.print(misc_ctr);
//move to row 4 and print counter and refresh time
lcd.setCursor(0, 3);
lcd.print("byte= ");
lcd.print(b_ctr);
lcd.setCursor(10, 3);
lcd.print("time ");
lcd.print(int_time);
cur_ctr = 0;
home_ctr = 0;
misc_ctr = 0;
clr_ctr = 0;
b_ctr = 0;
}
//the main loop is now just the hacked version of the Arduino Smartie code
void loop(){
rxbyte = serial_getch(); //this calls the 'function' serial_getch(), stores result in rxbyte
if (rxbyte == 254) //Matrix uses 254 for commands, if rxbyte = 254 the the code below runs
{
switch (serial_getch()) //calls serial_getch() to get the next byte from the PC
{
case 66: //former backlight on command
break;
case 70: //former backlight off command
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
cur_ctr++;
break;
case 72: //cursor home (reset display position)
lcd.command(2);
home_ctr++;
break;
case 74: //show underline cursor
lcd.command(0b00001110);
misc_ctr++;
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
misc_ctr++;
break;
case 76: //move cursor left
lcd.command(16);
misc_ctr++;
break;
case 77: //move cursor right
lcd.command(20);
misc_ctr++;
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.print(serial_getch()); //get each pattern byte
}
misc_ctr++;
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
misc_ctr++;
break;
case 86: //GPO OFF
//implement later
misc_ctr++;
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
misc_ctr++;
break;
case 88: //clear display, cursor home
lcd.command(1);
clr_ctr++;
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
misc_ctr++;
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
misc_ctr++;
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
misc_ctr++;
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/
case 0x5B: //Formerly [, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x5D: //Formerly ], now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7B: //Formerly left brace, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7D: //Formerly right brace, now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd
}
Here is my config ini:
[Communication Settings]
DisplayDLLName=matrix.dll
DisplayDLLParameters=COM11,9600
Baudrate=8
COMPort=1
USBPalm=0
ParallelPort=888
HDAlternativeAddressing=0
HDKS0073Addressing=0
HDTimingMultiplier=1
MX3USB=0
HTTPProxy=
HTTPProxyPort=0
RemoteHost=localhost
[General Settings]
RefreshRate=500
WinAmpLocation=C:\Program Files\Winamp\winamp.exe
BootDriverDelay=1
SETIEmail=test@test.com
DistLog=C:\koelog.txt
EmailPeriod=1
DLLPeriod=250
ScrollPeriod=500
AlwaysOnTop=1
Size=11
NewsRefresh=120
RandomScreens=0
FoldUsername=Test
GameRefresh=1
MBMRefresh=30
CheckUpdates=1
ColorOption=4
MinFadeContrast=0
SkinPath=images\
DLLContrast=132
DLLBrightness=128
HideOnStartup=0
AutoStart=0
AutoStartHidden=0
EmulateLCD=0
LCDType=7
Contrast=88
Brightness=26
CFContrast=66
CFBrightness=61
CFCGRomVersion=2
IRBrightness=3
ShutdownLine1=
ShutdownLine2=
ShutdownLine3=
ShutdownLine4=
[Screen 01]
Enabled=1
Theme=1
ShowTime=1
Sticky=0
Skip=0
InteractionTime=20
Interaction=0
Text01="a"
Text02="$CPUUsage%"
Text03="c"
Text04="d"
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 02]
Enabled=1
Theme=1
ShowTime=2
Sticky=0
Skip=0
InteractionTime=1
Interaction=0
Text01="A"
Text02="B"
Text03="C"
Text04="D"
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 03]
Enabled=0
Theme=1
ShowTime=6
Sticky=0
Skip=0
InteractionTime=15
Interaction=5
Text01="CPU @ $CPUSpeed MHz"
Text02="working @ $CPUUsage%%$Fill(20)$Bar($CPUUsage%,100,20)"
Text03="Memory: $Right($MemFree,$3%)$Fill(14)/ $Right($MemTotal,$3%) $Bar($MemFree,$PageTotal,20)"
Text04="Pagefile: $Right($PageFree$,$3%)Fill(14)/$Right($PageTotal,$4%) $Bar($PageFree,$PageTotal,20)"
NoScroll01=1
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 04]
Enabled=0
Theme=1
ShowTime=6
Sticky=0
Skip=3
InteractionTime=15
Interaction=5
Text01="$Tempname1:$Fill(12)$Temp1°C$Fill(20)$Tempname2:$Fill(33)$Temp2°C"
Text02="$Fanname1:$Fill(12)$FanS1rpm"
Text03="$Voltname1:$Fill(12)$Voltage1V$Fill(20)$Voltname2:$Fill(33)$Voltage2V"
Text04="working @ $CPUUsage%%$Fill(20)$Bar($CPUUsage%,100,20)"
NoScroll01=1
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 05]
Enabled=0
Theme=1
ShowTime=14
Sticky=0
Skip=0
InteractionTime=20
Interaction=1
Text01="ž You have $Email1 mails ž"
Text02="- $UpTime -"
Text03=""
Text04="- $Time(hh:nn:ss 'on' dddd d mmmm yyyy) -"
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=1
Center02=1
Center03=0
Center04=1
[Screen 06]
Enabled=0
Theme=1
ShowTime=5
Sticky=0
Skip=0
InteractionTime=20
Interaction=2
Text01="C:$Right($HDFree(C),$6%)MB of $Right($HDTotag(C),$2%)GB $Bar($HDFree(C),$HDTotal(C),21)"
Text02="D:$Right($HDFree(D),$6%)MB of $Right($HDTotag(D),$2%)GB $Bar($HDFree(D),$HDTotal(D),21)"
Text03="E:$Right($HDFree(E),$6%)MB of $Right($HDTotag(E),$2%)GB $Bar($HDFree(E),$HDTotal(E),21)"
Text04="F:$Right($HDFree(F),$6%)MB of $Right($HDTotag(F),$2%)GB $Bar($HDFree(F),$HDTotal(F),21)"
NoScroll01=1
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 07]
Enabled=0
Theme=1
ShowTime=5
Sticky=0
Skip=0
InteractionTime=20
Interaction=2
Text01="Downstr: $NetSpDownK(1)kB/s Upstr: $NetSpUpK(1)kB/s"
Text02="Download: $NetDownM(1)MB Upload: $NetUpM(1)MB"
Text03="Downstr: $NetSpDownK(2)kB/s Upstr: $NetSpUpK(2)kB/s"
Text04="Download: $NetDownM(2)MB Upload: $NetUpM(2)MB"
NoScroll01=0
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=1
Center02=1
Center03=1
Center04=1
[Screen 08]
Enabled=0
Theme=1
ShowTime=5
Sticky=0
Skip=0
InteractionTime=20
Interaction=2
Text01="$NetAdapter(1) "
Text02="Downstr: $NetSpDownK(1)kB/s Upstr: $NetSpUpK(1)kB/s"
Text03="Download: $NetDownM(1)MB Upload: $NetUpM(1)MB"
Text04="Total packets: $NetPackTot(1)"
NoScroll01=0
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=1
Center02=1
Center03=1
Center04=1
[Screen 09]
Enabled=0
Theme=1
ShowTime=5
Sticky=0
Skip=0
InteractionTime=15
Interaction=5
Text01="Work Units: $FOLDwu"
Text02="Team: $FOLDteam"
Text03="Score: $FOLDscore"
Text04="Rank: $FOLDrank"
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 10]
Enabled=0
Theme=1
ShowTime=5
Sticky=0
Skip=0
InteractionTime=15
Interaction=5
Text01="$SETIResults done with $SETICPUTime"
Text02="$SETIrankst out off $SETItotalusers users"
Text03="shareing this place with $SETIsharingrank users"
Text04="Completed more then $SETImoreWU% of all"
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 11]
Enabled=0
Theme=1
ShowTime=10
Sticky=0
Skip=0
InteractionTime=20
Interaction=1
Text01="$Rss(http://news.bbc.co.uk/rss/newsonline_uk_edition/world/rss091.xml,t,1) ž "
Text02="$Rss(http://news.bbc.co.uk/rss/newsonline_uk_edition/world/rss091.xml,d,1)"
Text03=""
Text04=""
NoScroll01=0
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=1
ContinueNextLine03=1
ContinueNextLine04=0
Center01=1
Center02=0
Center03=0
Center04=0
[Screen 12]
Enabled=0
Theme=1
ShowTime=10
Sticky=0
Skip=0
InteractionTime=20
Interaction=2
Text01="$Rss(http://sourceforge.net/export/rss2_projnews.php?group_id=122330&rss_fulltext=1,t,1) ž "
Text02="$Rss(http://sourceforge.net/export/rss2_projnews.php?group_id=122330&rss_fulltext=1,d,1)"
Text03=""
Text04=""
NoScroll01=0
NoScroll02=1
NoScroll03=1
NoScroll04=1
ContinueNextLine01=0
ContinueNextLine02=1
ContinueNextLine03=1
ContinueNextLine04=0
Center01=1
Center02=0
Center03=0
Center04=0
[Screen 13]
Enabled=0
Theme=1
ShowTime=8
Sticky=0
Skip=0
InteractionTime=1
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 14]
Enabled=0
Theme=1
ShowTime=8
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 15]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 16]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 17]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 18]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 19]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[Screen 20]
Enabled=0
Theme=1
ShowTime=4
Sticky=0
Skip=0
InteractionTime=0
Interaction=0
Text01=""
Text02=""
Text03=""
Text04=""
NoScroll01=0
NoScroll02=0
NoScroll03=0
NoScroll04=0
ContinueNextLine01=0
ContinueNextLine02=0
ContinueNextLine03=0
ContinueNextLine04=0
Center01=0
Center02=0
Center03=0
Center04=0
[POP Accounts]
Server00=
User00=""
Password00=""
Server01=
User01=""
Password01=""
Server02=
User02=""
Password02=""
Server03=
User03=""
Password03=""
Server04=
User04=""
Password04=""
Server05=
User05=""
Password05=""
Server06=
User06=""
Password06=""
Server07=
User07=""
Password07=""
Server08=
User08=""
Password08=""
Server09=
User09=""
Password09=""
Port_ssl00=
Port_ssl01=
Port_ssl02=
Port_ssl03=
Port_ssl04=
Port_ssl05=
Port_ssl06=
Port_ssl07=
Port_ssl08=
Port_ssl09=
[Game Servers]
GameServer01-01=cs.strikerz.net:27027
GameServer01-02=cs.strikerz.net:27047
GameServer01-03=213.208.119.10:27015
GameServer01-04=195.149.21.101:27025
GameServer02-01=cs.strikerz.net:27017
GameServer02-02=cs.strikerz.net:27027
GameServer02-03=cs.strikerz.net:27037
GameServer02-04=cs.strikerz.net:27067
GameServer03-01=195.149.21.121:27025
GameServer03-02=195.149.21.18:27035
GameServer03-03=195.149.21.112:27025
GameServer03-04=213.208.119.19:27065
GameServer04-01=213.208.119.10:27015
GameServer04-02=195.149.21.101:27025
GameServer04-03=195.149.21.15:27035
GameServer04-04=192.168.0.18
GameServer05-01=strikerz.net:27017
GameServer05-02=213.208.119.11:27025
GameServer05-03=192.168.0.18
GameServer05-04=195.149.21.18:27035
GameServer06-01=cs.strikerz.net:27017
GameServer06-02=cs.strikerz.net:27027
GameServer06-03=cs.strikerz.net:27037
GameServer06-04=cs.strikerz.net:27047
GameServer07-01=cs.strikerz.net:27027
GameServer07-02=cs.strikerz.net:27067
GameServer07-03=cs.strikerz.net:27077
GameServer07-04=cs.strikerz.net:27027
GameServer08-01=192.168.9.2
GameServer08-02=192.168.9.2
GameServer08-03=195.149.21.112:27025
GameServer08-04=213.208.119.19:27065
GameServer09-01=213.208.119.10:27015
GameServer09-02=195.149.21.101:27025
GameServer09-03=195.149.21.15:27035
GameServer09-04=195.149.21.121:27035
GameServer10-01=cs.strikerz.net:27017
GameServer10-02=213.208.119.11:27025
GameServer10-03=195.149.21.121:27025
GameServer10-04=195.149.21.18:27035
GameServer11-01=strikerz.net:27017
GameServer11-02=213.208.119.19:27065
GameServer11-03=213.208.119.10:27015
GameServer11-04=195.149.21.101:27025
GameServer12-01=cs.strikerz.net:27017
GameServer12-02=cs.strikerz.net:27027
GameServer12-03=cs.strikerz.net:27037
GameServer12-04=cs.strikerz.net:27067
GameServer13-01=213.189.16.85:27015
GameServer13-02=127.0.0.1
GameServer13-03=195.149.21.112:27025
GameServer13-04=213.208.119.19:27065
GameServer14-01=213.208.119.10:27015
GameServer14-02=195.149.21.101:27025
GameServer14-03=195.149.21.15:27035
GameServer14-04=192.168.0.18
GameServer15-01=strikerz.net:27017
GameServer15-02=213.208.119.11:27025
GameServer15-03=192.168.0.18
GameServer15-04=195.149.21.18:27035
GameServer16-01=cs.strikerz.net:27017
GameServer16-02=cs.strikerz.net:27027
GameServer16-03=cs.strikerz.net:27037
GameServer16-04=cs.strikerz.net:27047
GameServer17-01=192.168.10.4:27057
GameServer17-02=cs.strikerz.net:27067
GameServer17-03=cs.strikerz.net:27077
GameServer17-04=cs.strikerz.net:27087
GameServer18-01=195.149.21.121:27025
GameServer18-02=195.149.21.18:27035
GameServer18-03=195.149.21.112:27025
GameServer18-04=213.208.119.19:27065
GameServer19-01=213.208.119.10:27015
GameServer19-02=195.149.21.101:27025
GameServer19-03=195.149.21.15:27035
GameServer19-04=195.149.21.121:27035
GameServer20-01=127.0.0.1
GameServer20-02=213.208.119.11:27025
GameServer20-03=195.149.21.121:27025
GameServer20-04=195.149.21.18:27035
[Actions]
Action01Variable=$Email1
Action01Condition=0
Action01ConditionValue=0
Action01Action=GPO(1,0)
Action02Variable=$Email1
Action02Condition=0
Action02ConditionValue=0
Action02Action=GotoScreen(5)
Action03Variable=$MObutton(K)
Action03Condition=2
Action03ConditionValue=1
Action03Action=NextTheme
Action04Variable=$MObutton(J)
Action04Condition=2
Action04ConditionValue=1
Action04Action=GPOToggle(2)
Action05Variable=$MObutton(P)
Action05Condition=2
Action05ConditionValue=1
Action05Action=FreezeScreen
Action06Variable=$MObutton(Q)
Action06Condition=2
Action06ConditionValue=1
Action06Action=BacklightToggle
Action07Variable=$MObutton(R)
Action07Condition=2
Action07ConditionValue=1
Action07Action=WALastTrack
Action08Variable=$MObutton(F)
Action08Condition=2
Action08ConditionValue=1
Action08Action=WANextTrack
Action09Variable=$MObutton(L)
Action09Condition=2
Action09ConditionValue=1
Action09Action=NextScreen
Action10Variable=$MObutton(A)
Action10Condition=2
Action10ConditionValue=1
Action10Action=WAPlay
Action11Variable=$MObutton(B)
Action11Condition=2
Action11ConditionValue=1
Action11Action=WAStop
Action12Variable=$MObutton(C)
Action12Condition=2
Action12ConditionValue=1
Action12Action=WAPause
Action13Variable=$MObutton(D)
Action13Condition=2
Action13ConditionValue=1
Action13Action=WANextTrack
Action14Variable=$MObutton(E)
Action14Condition=2
Action14ConditionValue=1
Action14Action=WALastTrack
[Versions]
ConfigFileFormat=1.0
ScreenTextSyntax=1.0
yay hwinfo plugin finished!
Belial88:
Mee_n_Mac:
Let's zero in on the last test above as my (limited) buffer never caught lines3-4 of screen #2 being commanded. So 2 screens enabled, screen 1 'time to show' = 1 sec, screen 2 'time to show' = 2 sec, refresh interval = 500 msec, no scrolling or other fancy stuff and no transition enabled (= none).Belial88:
What should I take video of exactly?Screen 1
line1 = a
line2 = $CPUUsage%
line3 = c
line4 = b
Screen 2
line1 = A
line2 = B
line3 = C
line4 = D
Here’s my Smartie config.ini file. I note my “Screen 2” is really Screen 13 (only 1 and 13 are enabled).
[attachment=0]config - Copy.txt[/attachment]Let’s see if C, D show up on your vid. Also any other video where lines1-2 are bugged out. Use the normal, unhacked Smartie code for these.
Sorry, I’m a bit confused. You mean use the plain smartie code from like the beginning that I quoted, or the code you last listed? You say test interchangeably to refer to the smartie GUI setup and the code (or i am mistaking it as such). Which of these?:
Neither actually. What we want is Smartie code that has all the correct pin numbers for your wiring, but not any of the last ‘test’ codes. Let me see if I can find it.
new baseline code - does A0, A1 ADC stuff using [, {, ], } but is otherwise “non-test”
#include <VarSpeedServo.h> //variable speed servo library
#include <LiquidCrystal.h>
//declare the constants to be used
#define LEDPIN 13 //pin attached to LED
#define servoPIN 9 //Servo control line
#define SWitchPIN 2 //input from N.O. momentary switch
#define redPIN 11 //PWM pin for red LED backlight
#define greenPIN 10 //PWM pin for green LED backlight
#define bluePIN 12 //PWM pin for blue LED backlight
#define rsPIN 8 //reset pin for LCD
#define enablePIN 7 //enable pin for LCD
#define d4PIN 4 //data pin4 for LCD
#define d5PIN 5 //data pin5 for LCD
#define d6PIN 6 //data pin6 for LCD
#define d7PIN 3 //data pin7 for LCD
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
#define posOpenCMD 1900 //Define Clockwise Servo position in usec
#define posCloseCMD 600 //Define CounterClockwise Servo position in usec
#define DBdelay 2000 //Min time needed btw any 2 button presses, in msec
#define fastSPD 100 //speed setting; 1 = slowest, 255 is fastest (???)
#define slowSPD 15 //Speed Servo/Door opens and closes (15 is good average)
#define DIV_1 1.0 //gain correction for A0 channel
#define DIV_2 1.0 //note it's 1.0, not 1, to get full floating point accuracy
#define V_REF 2.54 //use the measured Aref voltage
//declare the variables used
volatile boolean doorOPEN = false; //desired door state set to closed
byte rxbyte = 0; //rxbyte is the received byte from Smartie
byte temp = 0;
volatile unsigned long SWtime = 0; //holds the time of the last valid switch push
float voltage1 = 0.0; // calculated voltage for A0
float voltage2 = 0.0; // calculated voltage for A1
LiquidCrystal lcd(rsPIN, enablePIN, d4PIN, d5PIN, d6PIN, d7PIN);
VarSpeedServo myServo; //create a servo object
void setup() {
//set the pins to be ins or outs
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW); //turn LED off
pinMode(servoPIN, OUTPUT);
pinMode(SWitchPIN, INPUT_PULLUP);
pinMode(redPIN, OUTPUT);
pinMode(greenPIN, OUTPUT);
pinMode(bluePIN, OUTPUT);
attachInterrupt(1, SW_ISR, FALLING);
Serial.begin(9600);
lcd.begin(numCols, numRows);
lcd.clear();
analogWrite(bluePIN,0); //Blue brightness 255-0
analogWrite(redPIN,255); //Red brightness 255-0
analogWrite(greenPIN,255); //Green brightness 255-0
analogReference(INTERNAL); //use the internal 2.56v ADC reference
//CMD the servo to close the door
myServo.attach(servoPIN); // Attach the servo
myServo.slowmove(posCloseCMD, fastSPD); // Tell servo to go to closed position
//put a hello world on the LCD
lcd.home();
lcd.print("Line 1");
lcd.setCursor(10, 1);
lcd.print("Line 2");
lcd.setCursor(20, 2);
lcd.print("Line 3");
lcd.setCursor(30, 3);
lcd.print("Line 4");
delay(2000);
}
//the following function is the ISR that responds to the push button switch
//it commands the door to open or close at slow speed
void SW_ISR(){
//debounce the switch by ignoring any interrupt that occurs too soon after the prior one
unsigned long Time = millis();
if(Time - SWtime > DBdelay){ //enough time has elapsed, not a switch bounce
SWtime = Time; //save new time of switch push
doorOPEN = !doorOPEN; //reverse desired door state
if(doorOPEN == true){
digitalWrite(LEDPIN, HIGH); //turn LED on
myServo.slowmove(posOpenCMD, slowSPD); //tell servo to go to open position
}
else {
digitalWrite(LEDPIN, LOW); //turn LED off
myServo.slowmove(posCloseCMD, slowSPD); //tell servo to go to closed position
}
}
}
//this function is used by the smartie code to get data from the PC
byte serial_getch(){
int incoming;
while (Serial.available()==0){
}
// read the incoming byte:
incoming = Serial.read();
return (byte) (incoming &0xff);
}
//the main loop is now just the hacked version of the Arduino Smartie code
void loop(){
rxbyte = serial_getch(); //this calls the 'function' serial_getch(), stores result in rxbyte
if (rxbyte == 254) //Matrix uses 254 for commands, if rxbyte = 254 the the code below runs
{
switch (serial_getch()) //calls serial_getch() to get the next byte from the PC
{
case 66: //former backlight on command
break;
case 70: //former backlight off command
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
break;
case 72: //cursor home (reset display position)
lcd.command(2);
break;
case 74: //show underline cursor
lcd.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
break;
case 76: //move cursor left
lcd.command(16);
break;
case 77: //move cursor right
lcd.command(20);
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.print(serial_getch()); //get each pattern byte
}
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
break;
case 88: //clear display, cursor home
lcd.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/
case 0x5B: //Formerly [, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x5D: //Formerly ], now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7B: //Formerly left brace, now does A0 ADC
voltage1 = DIV_1 * float(analogRead(A0)) * V_REF/1023.0;
lcd.print(voltage1, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0x7D: //Formerly right brace, now does A1 ADC
voltage2 = DIV_2 * float(analogRead(A1)) * V_REF/1023.0;
lcd.print(voltage2, 3);
rxbyte = 0x76; //will cause v to be displayed
break;
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd
}
IIRC the above code correctly displayed the A0 and A1 voltages, updating the line when you used 2 pages and had the line alternate btw [ and { or ] and }. But lines 1 and 2, just doing normal stuff, didn’t always display properly. So use the above code and see if the display “bugs out”.
Okay I’ll play around with that code (with correct pinouts ofc) and show video of it bugging out. It’s definitely still bugging out.
Okay so using that new code, and in LCD Smartie using:
500/500, 2 screens at 1s each, no scrolling lines:
$dll(hwinfo,1,3|2|1,0) /$dll(hwinfo,1,3|2|1,0)
$dll(hwinfo,1,6|2|1,0) /$dll(hwinfo,1,6|2|1,0)
CPU VCORE [ /CPU VCORE {
CPU VRIN ] /CPU VRIN }
and then also trying:
asdfasdf / asdfasdfdd
asdfasdf/asdfasdfdd
CPU VCORE [ /CPU VCORE {
CPU VRIN ] /CPU VRIN }
finally:
12345678901234567890/09876543210987654321
12345678901234567890/09876543210987654321
12345678901234567890/09876543210987654321
12345678901234567890/09876543210987654321
Uploading video.
you know… i think i only get the error when I do the voltage thing? Man this is confusing. because like that last test worked fine…