I am displaying text using this code.
#include <U8glib.h>
U8GLIB_SSD1306_128X64 u8g(12, 11, 8, 9, 10);
int Buffer[128];int Buffer2[128];int max=0;
void pageEMG();
void recordEMG();
void pageECG();
void recordECG();
void pageBP();
void recordBP();
void clear_screen();
const int pageCount = 10;
int p;
void (*pages[pageCount])() = {clear_screen,recordEMG,pageEMG,clear_screen,recordECG,pageECG,clear_screen,recordBP,pageBP,clear_screen};
int duration [pageCount] = { 100,5000,10000,100,5000,10000,100,5000,10000,100};
void setup() {
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1);
p = 0;
Serial.begin(9600);
}
void loop()
{
u8g.firstPage();
do {
(pages[p])();
} while( u8g.nextPage() );
delay(duration[p]);
p = p+1;
if (p == pageCount)
p=0;
}
void recordEMG(){
for(int x=0;x<128;x++)
{
Buffer[x]=analogRead(A2).091;
Serial.println(Buffer[x]);
delay(35);
}
u8g.drawStr( 0, 20, "Reading EMG...");
}
void pageEMG() {
for(int x = 0;x < 127;x++)
{
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 20, "EMG");
u8g.drawLine(x, Buffer[x], x+1, Buffer[x+1]); //OP to OLED for BP
}}
void recordECG(){
for(int x=0;x<128;x++)
{
Buffer[x]=analogRead(A0)*.08;
Serial.println(Buffer[x]);
delay(35);
}
u8g.drawStr( 0, 20, "Reading ECG...");
}
void pageECG() {
for(int x = 0;x < 127;x++)
{
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 20, "BP");
u8g.drawLine(x, Buffer[x], x+1, Buffer[x+1]); //OP to OLED for BP
}}
void recordBP(){
for(int x=0;x<128;x++)
{
Buffer[x]=analogRead(A1)*.091;
Serial.println(Buffer[x]);
delay(35);
}
u8g.drawStr( 0, 20, "Reading BP...");
}
void pageBP() {
for(int x = 0;x < 127;x++)
{
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 20, "BP");
u8g.drawLine(x, Buffer[x], x+1, Buffer[x+1]); //OP to OLED for BP
}}
void clear_screen(void) {
u8g.setColorIndex(0);
u8g.drawBox(1, 1, 64, 128);
}
And my text is coming inverted.
Why is this happening?