i have well connected i2c oled display(128x32) with teensy LC(pin18,19) . using this code
oled is being update every half second . but value of "Patch" some time missing on display .not showing in right increament . looking like
value of "Patch" printing in serial monitor with right increament like
please reply . if this kind of problem is fixed
..........thank you..............
C++:
#include <EEPROM.h>
#include <Keypad.h>
#include <MIDI.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels.
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) -1
#define SCREEN_ADDRESS 0x3C // See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const byte ROWS = 14; //
const byte COLS = 6; //
char keys[ROWS][COLS] = {
{ 1, 2, 3, 4, 5, 6},
{ 7, 8, 9,10,11,12},
{13,14,15,16,17,18},
{19,20,21,22,23,24},
{25,26,27,28,29,30},
{31,32,33,34,35,36},
{37,38,39,40,41,42},
{43,44,45,46,47,48},
{49,50,51,52,53,54},
{55,56,57,58,59,60},
{61,62,63,64,65,66},
{67,68,69,70,71,72},
{73,74,75,76,77,78},
{79,80,81,82,83,84}
};
byte rowPins[ROWS] = {2,3,4,5,6,7,8,9,10,11,12,14,15,16 };
byte colPins[COLS] = {21,22,23,24,25,26};
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define PATCH_UP 52
byte Patch=0;
void setup() {
Serial.begin(9600);
display.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
Serial.println("SETUP DONE");
}
void loop() {
if (kpd.getKeys())
{
for (int i=0; i<LIST_MAX; i++)
{ int mykey = kpd.key[i].kchar;
if (( kpd.key[i].stateChanged ) && (mykey==PATCH_UP)) //
{
switch (kpd.key[i].kstate) {
case PRESSED:
Patch++;
SCN_PRINT_NUMBER(Patch);
delay(500);
}
} //-------------------------------------------------------
}
}
Patch++;
SCN_PRINT_NUMBER(Patch);
Serial.println(Patch);
delay(500);
}
void SCN_PRINT_NUMBER(int n) {
display.begin();
display.clearDisplay(); // Clear display buffer
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.setTextSize(2);
display.print(n);
display.display();
}
1...2...3...3...5...5...7 when printing last value again , it also print with another cursor position of text automatic.value of "Patch" printing in serial monitor with right increament like
1...2...3...4...5...6...7...8...9. i have tested three new displays. but getting same result..please reply . if this kind of problem is fixed
..........thank you..............