diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-07-16 12:00:14 +1000 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-07-16 12:00:14 +1000 |
commit | 77188df69a7cdfe7e9b63661ee623f0182f6621e (patch) | |
tree | 18dcf5b017a83823fc051d2eede0ddf9632061a1 | |
parent | ebd8a8a5734c0f42c1cf388b37f3d90bfa47a9c6 (diff) | |
download | 2021-arduino-obd-77188df69a7cdfe7e9b63661ee623f0182f6621e.tar.gz 2021-arduino-obd-77188df69a7cdfe7e9b63661ee623f0182f6621e.tar.bz2 2021-arduino-obd-77188df69a7cdfe7e9b63661ee623f0182f6621e.zip |
Update Nano Logger
-rw-r--r-- | nanologger/README.txt | 3 | ||||
-rw-r--r-- | nanologger/SH1106.cpp | 26 | ||||
-rw-r--r-- | nanologger/SSD1306.cpp | 6 | ||||
-rw-r--r-- | nanologger/SSD1306.h | 9 |
4 files changed, 26 insertions, 18 deletions
diff --git a/nanologger/README.txt b/nanologger/README.txt index 5a1e5cf..6fbb9b5 100644 --- a/nanologger/README.txt +++ b/nanologger/README.txt @@ -1,5 +1,4 @@ -This is the source code for the Arduino OBD-II data logger, which displays (on a 128x64 OLED display module) and records (to a SD card) a selected set of OBD-II data. For hardware configuration and wiring guide, please refer to: -http://obd.arduinodev.com +This is the source code for the Arduino OBD-II data logger, which displays (on a 128x64 OLED display module) and records (to a SD card) a selected set of OBD-II data. The recorded data is stored in CSV format and the file can be illustrated into a graphic chart by a free service at: http://freematics.com/chart/ diff --git a/nanologger/SH1106.cpp b/nanologger/SH1106.cpp index b1e57ef..a46c821 100644 --- a/nanologger/SH1106.cpp +++ b/nanologger/SH1106.cpp @@ -35,13 +35,13 @@ void LCD_SH1106::clear(byte x, byte y, byte width, byte height) WriteCommand(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0 WriteCommand(SSD1306_SETSTARTLINE | 0x0); // line #0 - // save I2C bitrate - uint8_t twbrbackup = TWBR; - TWBR = 18; // upgrade to 400KHz! - height >>= 3; width >>= 3; y >>= 3; +#ifdef TWBR + uint8_t twbrbackup = TWBR; + TWBR = 18; // upgrade to 400KHz! +#endif for (byte i = 0; i < height; i++) { // send a bunch of data in one xmission WriteCommand(0xB0 + i + y);//set page address @@ -57,9 +57,10 @@ void LCD_SH1106::clear(byte x, byte y, byte width, byte height) Wire.endTransmission(); } } - - setCursor(0, 0); +#ifdef TWBR TWBR = twbrbackup; +#endif + setCursor(0, 0); } size_t LCD_SH1106::write(uint8_t c) @@ -72,8 +73,10 @@ size_t LCD_SH1106::write(uint8_t c) return 1; } +#ifdef TWBR uint8_t twbrbackup = TWBR; TWBR = 18; // upgrade to 400KHz! +#endif #ifndef MEMORY_SAVING if (m_font == FONT_SIZE_SMALL) { #endif @@ -158,15 +161,18 @@ size_t LCD_SH1106::write(uint8_t c) } } #endif +#ifdef TWBR TWBR = twbrbackup; +#endif return 1; } void LCD_SH1106::writeDigit(byte n) { +#ifdef TWBR uint8_t twbrbackup = TWBR; TWBR = 18; // upgrade to 400KHz! - +#endif if (m_font == FONT_SIZE_SMALL) { Wire.beginTransmission(I2C_ADDR); Wire.write(0x40); @@ -316,13 +322,17 @@ void LCD_SH1106::writeDigit(byte n) } m_col += (m_flags & FLAG_PIXEL_DOUBLE_H) ? 30 : 16; } +#ifdef TWBR TWBR = twbrbackup; +#endif } void LCD_SH1106::draw(const PROGMEM byte* buffer, byte width, byte height) { +#ifdef TWBR uint8_t twbrbackup = TWBR; TWBR = 18; // upgrade to 400KHz! +#endif WriteCommand(SSD1306_SETLOWCOLUMN | 0x0); // low col = 0 WriteCommand(SSD1306_SETHIGHCOLUMN | 0x0); // hi col = 0 @@ -346,7 +356,9 @@ void LCD_SH1106::draw(const PROGMEM byte* buffer, byte width, byte height) Wire.endTransmission(); } } +#ifdef TWBR TWBR = twbrbackup; +#endif m_col += width; } diff --git a/nanologger/SSD1306.cpp b/nanologger/SSD1306.cpp index 7f7b8e8..75662e8 100644 --- a/nanologger/SSD1306.cpp +++ b/nanologger/SSD1306.cpp @@ -1,5 +1,5 @@ #include <avr/pgmspace.h> -#include <util/delay.h> +//#include <util/delay.h> #include <stdlib.h> #include <Wire.h> #include "SSD1306.h" @@ -238,8 +238,10 @@ void SSD1306::fill(unsigned char dat) ssd1306_command(0x10);//set higher column address ssd1306_command(0xB0);//set page address +#ifdef TWBR uint8_t twbrbackup = TWBR; TWBR = 18; // upgrade to 400KHz! +#endif for (byte i=0; i<(SSD1306_LCDHEIGHT/8); i++) { // send a bunch of data in one xmission @@ -256,7 +258,9 @@ void SSD1306::fill(unsigned char dat) Wire.endTransmission(); } } +#ifdef TWBR TWBR = twbrbackup; +#endif } void SSD1306::draw8x8(byte* buffer, uint8_t x, uint8_t y) diff --git a/nanologger/SSD1306.h b/nanologger/SSD1306.h index aaa3534..ae7f339 100644 --- a/nanologger/SSD1306.h +++ b/nanologger/SSD1306.h @@ -1,11 +1,4 @@ -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#define BLACK 0 -#define WHITE 1 +#include "Arduino.h" #define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D // Address for 128x32 is 0x3C |