Download the latest and greatest version of the library, dump the PCD8544 directory to your Arduino libraries folder, restart the Arduino IDE. The display needs to be connected as follows: SCLK 8, SDIN 9, D/C 10, RST 11, SCE 12.
-#include <LiquidCrystal.h>
+// No longer using HD44780-comaptible display,
+// Moving to a brand new world of dot-matrix display tech!
+// Using LCD library from http://code.google.com/p/pcd8544/
+#include <PCD8544.h>
+
#include <TimerOne.h>
#include <EEPROM.h>
#include <TimerOne.h>
#include <EEPROM.h>
unsigned char current_model; // Using uchar to spend a single byte of mem..
// ----------------- Display related stuffs --------------------
unsigned char current_model; // Using uchar to spend a single byte of mem..
// ----------------- Display related stuffs --------------------
-LiquidCrystal lcd( 12, 11, 10, 6, 7, 8, 9);
-// Parameters are: rs, rw, enable, d4, d5, d6, d7 pin numbers.
+PCD8544 lcd( 8, 9, 10, 11, 12);
+// Param: sclk, sdin, dc, reset, sce
// ----------------- PPM related stuffs ------------------------
// The PPM generation is handled by Timer0 interrupts, and needs
// ----------------- PPM related stuffs ------------------------
// The PPM generation is handled by Timer0 interrupts, and needs
pinMode(4, OUTPUT); // s2
pinMode(5, OUTPUT); // e
pinMode(4, OUTPUT); // s2
pinMode(5, OUTPUT); // e
lcd.print("Starting....");
lcd.print("Starting....");
Serial.begin(9600);
Serial.println("Starting....");
Serial.begin(9600);
Serial.println("Starting....");
delay(500);
model_defaults();
delay(500);
model_defaults();
set_timer( seplength );
Timer1.initialize(framelength);
Timer1.attachInterrupt(ISR_timer);
set_timer( seplength );
Timer1.initialize(framelength);
Timer1.attachInterrupt(ISR_timer);
lcd.setCursor(0 , 0);
lcd.print("D/R switch ");
lcd.print( no + 1 );
lcd.setCursor(0 , 0);
lcd.print("D/R switch ");
lcd.print( no + 1 );
+ //lcd.print(" ");
+
+ lcd.setCursor(0 , 1);
+ lcd.print(" ");
lcd.setCursor(0 , 1);
lcd.print("Input ");
lcd.print(in+1);
lcd.setCursor(0 , 1);
lcd.print("Input ");
lcd.print(in+1);
lcd.setCursor(0 , 0);
lcd.print("D/R switch ");
lcd.print( menu_substate - 3 );
lcd.setCursor(0 , 0);
lcd.print("D/R switch ");
lcd.print( menu_substate - 3 );
+
+
+ lcd.setCursor(0 , 1);
+ lcd.print(" ");
lcd.setCursor(0 , 1);
lcd.print( state ? "HI" : "LO" );
lcd.print(" Value :");
lcd.setCursor(0 , 1);
lcd.print( state ? "HI" : "LO" );
lcd.print(" Value :");
+ if ( check_key( KEY_UP) || check_key(KEY_DOWN))
+ lcd.clear();
+
if ( displaystate != MENU )
{
menu_substate = 0;
if ( displaystate != MENU )
{
menu_substate = 0;
digitalWrite(13, digitalRead(13) ^ 1 );
switch ( displaystate )
{
case VALUES:
int current_input;
digitalWrite(13, digitalRead(13) ^ 1 );
switch ( displaystate )
{
case VALUES:
int current_input;
for (current_input=0; current_input<MAX_INPUTS; current_input++) {
for (current_input=0; current_input<MAX_INPUTS; current_input++) {
- // In channel value display, do a simple calc
- // of the LCD row & column location. With 8 channels
- // we can fit eight channels as percentage values on
- // a simple 16x2 display...
- if ( current_input < 4 )
- {
- col = current_input * 4;
- row = 0;
- }
- else
- {
- col = (current_input-4) * 4;
- row = 1;
- }
+ if (row == 5)
+ {
+ row = 1;
+ col = 44;
+ }
+
// Overwriting the needed positions with
// blanks cause less display-flicker than
// actually clearing the display...
lcd.setCursor(col, row);
// Overwriting the needed positions with
// blanks cause less display-flicker than
// actually clearing the display...
lcd.setCursor(col, row);
+ lcd.print( current_input+1);
+ lcd.print(":");
// Display uses percents, while PPM uses ratio....
// New format on stick values
lcd.print( (int)model.stick[current_input] );
// Display uses percents, while PPM uses ratio....
// New format on stick values
lcd.print( (int)model.stick[current_input] );
lcd.print("Battery level: ");
lcd.setCursor(0 , 1);
lcd.print("Battery level: ");
lcd.setCursor(0 , 1);
+ lcd.print( " ");
+ lcd.setCursor(0 , 1);
lcd.print( (float)battery_val/10);
lcd.print("V");
if ( battery_val < BATTERY_LOW ) lcd.print(" - WARNING");
lcd.print( (float)battery_val/10);
lcd.print("V");
if ( battery_val < BATTERY_LOW ) lcd.print(" - WARNING");
int minutes;
int seconds;
int minutes;
int seconds;
lcd.print("Timer: ");
lcd.print( clock_timer.running ? "Running" : "Stopped" );
lcd.setCursor(5 , 1);
lcd.print("Timer: ");
lcd.print( clock_timer.running ? "Running" : "Stopped" );
lcd.setCursor(5 , 1);
+ lcd.print(" ");
+ lcd.setCursor(5 , 1);
if ( clock_timer.running )
{
clock_timer.value = millis() - (clock_timer.start + clock_timer.init);
if ( clock_timer.running )
{
clock_timer.value = millis() - (clock_timer.start + clock_timer.init);
lcd.print("Model #: ");
lcd.print( (int)current_model );
lcd.setCursor(0 , 1);
lcd.print("Model #: ");
lcd.print( (int)current_model );
lcd.setCursor(0 , 1);
switch ( menu_mainstate )
{
case TOP:
switch ( menu_mainstate )
{
case TOP:
lcd.print("In MENU mode!");
lcd.setCursor(0 , 1);
lcd.print("In MENU mode!");
lcd.setCursor(0 , 1);
- lcd.print("Esc UP. Scrl DN.");
+ lcd.print("UP to quit.");
+ lcd.setCursor(0 , 2);
+ lcd.print("DOWN to scroll");
+
menu_substate = 0;
if ( check_key(KEY_UP) ) {
displaystate = VALUES;
menu_substate = 0;
if ( check_key(KEY_UP) ) {
displaystate = VALUES;
return;
}
else if ( check_key(KEY_DOWN) ) {
return;
}
else if ( check_key(KEY_DOWN) ) {
menu_mainstate = INVERTS;
return;
}
menu_mainstate = INVERTS;
return;
}
if ( check_key(KEY_UP) ) {
menu_mainstate = TOP;
if ( check_key(KEY_UP) ) {
menu_mainstate = TOP;
return;
}
else if ( check_key(KEY_DOWN) ) {
menu_mainstate = DUALRATES;
return;
}
else if ( check_key(KEY_DOWN) ) {
menu_mainstate = DUALRATES;
if ( check_key(KEY_UP) ) {
menu_mainstate = INVERTS;
if ( check_key(KEY_UP) ) {
menu_mainstate = INVERTS;
return;
}
if ( check_key(KEY_DOWN) ) {
menu_mainstate = EXPOS;
return;
}
if ( check_key(KEY_DOWN) ) {
menu_mainstate = EXPOS;
return;
}
if ( check_key(KEY_RIGHT) ) {
return;
}
if ( check_key(KEY_RIGHT) ) {
// on the time-horizon :P
if ( check_key(KEY_UP ) ) {
menu_mainstate = DUALRATES;
// on the time-horizon :P
if ( check_key(KEY_UP ) ) {
menu_mainstate = DUALRATES;
return;
}
#ifdef DEBUG
if ( check_key(KEY_DOWN ) ) {
menu_mainstate = DEBUG_DUMP;
return;
}
#ifdef DEBUG
if ( check_key(KEY_DOWN ) ) {
menu_mainstate = DEBUG_DUMP;
return;
}
#else
if ( check_key(KEY_DOWN ) ) {
menu_mainstate = TOP;
return;
}
#else
if ( check_key(KEY_DOWN ) ) {
menu_mainstate = TOP;
if ( check_key(KEY_UP ) ) {
// FIXME: Remember to update the "Scroll up" state!
menu_mainstate = EXPOS;
if ( check_key(KEY_UP ) ) {
// FIXME: Remember to update the "Scroll up" state!
menu_mainstate = EXPOS;
return;
} else if ( check_key(KEY_DOWN ) ) {
menu_mainstate = SAVE;
return;
} else if ( check_key(KEY_DOWN ) ) {
menu_mainstate = SAVE;