/*
HelloWorld.pde
"Hello World!" example code.
Before compiling: Please remove comment from the constructor of the
connected graphics display (see below).Universal 8bit Graphics Library, Google Code Archive - Long-term storage for Google Code Project Hosting.
Copyright (c) 2012, olikraus@gmail.com
All rights reserved.Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
#include "U8glib.h"
U8GLIB_NHD27OLED_GR u8g(3, 4, 5, 6); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10 , A0 = 6int sensorValue = 0;
void drawanalog(){
//analogReadResolution(12);
sensorValue = analogRead(A0);
u8g.setPrintPos(80, 62);
u8g.print(sensorValue);
}
void setup(void) {
analogReadResolution(12);
// flip screen, if required
// u8g.setRot180();// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);
if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3);
}
u8g.setFont(u8g_font_unifont);
//u8g.setFont(u8g_font_osb21);
}void loop(void) {
// picture loop
u8g.firstPage();
do {
//draw();
drawanalog();
} while( u8g.nextPage() );// rebuild the picture after some delay
delay(50);}
Here is the quick and dirty code i hacked together, even with the 50ms delay it is not usable.
going to try and get it working on the hardware spi..