Skip to content

Commit

Permalink
initial push of unfinished oLed displays
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Stanley committed Jan 7, 2018
1 parent cfa134d commit 60959cc
Show file tree
Hide file tree
Showing 159 changed files with 126,007 additions and 0 deletions.
47 changes: 47 additions & 0 deletions rover/core/servers/oLed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Deepstream Data to Four Oleds

First, you will need the dependency "screen" to launch these scripts on startup:

sh
```
sudo apt-get install screen;
```

This project consists of four oleds attached to our rover. The python scripts on launch will consist of
oLed1.py
oLed2.py
oLed3.py
oLed4.py

These scripts can be launched via a crontab.

sh
```
sudo vim /etc/crontab
```

create these lines in crontab:


```
@reboot root /usr/bin/screen -dmS imu && /usr/bin/screen -X stuff 'cd /home/pi/TitanRover2018/rover/core/servers/oLed/ && /usr/bin/python oLed1.py\015';
@reboot root /usr/bin/screen -dmS imu && /usr/bin/screen -X stuff 'cd /home/pi/TitanRover2018/rover/core/servers/oLed/ && /usr/bin/python oLed2.py\015';
@reboot root /usr/bin/screen -dmS imu && /usr/bin/screen -X stuff 'cd /home/pi/TitanRover2018/rover/core/servers/oLed/ && /usr/bin/python oLed3.py\015';
@reboot root /usr/bin/screen -dmS imu && /usr/bin/screen -X stuff 'cd /home/pi/TitanRover2018/rover/core/servers/oLed/ && /usr/bin/python oLed4.py\015';
```

As of right now, only oLed1.py has been written, though the code is mostly reuseable.

For information on the process of assigning udev rules to each serial to usb device attached, as well as find the schematics for printing the custom 4 oLed board, please read schematics/README.md

For the u8glib library necessary to flash the 4 arduinos, you need to transfer:
arduino oLed1/U8glib_Arduino-1.19.1
to your Arduino Library folder.

Each arduino pin 10, is the RX pin for the data stream coming from each associated python script.
oLed1.py -> arduino1
oLed2.py -> arduino2
oLed3.py -> arduino3
oLed4.py -> arduino4
Each arduino and oled will share 5v power and ground from the usb attached to
oLed1 -> arduino1 (CP2102 - serial number: 1000)
6 changes: 6 additions & 0 deletions rover/core/servers/oLed/arduino oLed1/.vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"port": "/dev/ttyUSB0",
"board": "arduino:avr:mega",
"configuration": "cpu=atmega2560",
"sketch": "Serial-to-OLED.ino"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"/home/audstanley/Arduino-1.8.5/hardware/arduino/avr/cores/arduino"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"/home/audstanley/Arduino-1.8.5/hardware/arduino/avr/cores/arduino"
]
},
"intelliSenseMode": "clang-x64"
}
],
"version": 3
}
196 changes: 196 additions & 0 deletions rover/core/servers/oLed/arduino oLed1/Serial-to-OLED.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
#include <SoftwareSerial.h>
#include "U8glib.h"

SoftwareSerial rxData(10, NOT_A_PIN);
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK);
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST); // Fast I2C / TWI

const char* skull = "x";
const char* solidCircle = "F";
const char* starShipEnterprise = "®";

const int rightLineLength = 7;

char c;

// convert String to char array
// Don't forget char \0
// Left side of OLED screen
char dataHold[20] = ".................\0";
char line0[rightLineLength] = ".....\0";
char line1[rightLineLength] = ".....\0";
char line2[rightLineLength] = ".....\0";
char line3[rightLineLength] = ".....\0";
char line4[rightLineLength] = ".....\0";
char line5[rightLineLength] = ".....\0";

// Right Side of OLED screen
char line6[14] = "............\0";


unsigned int delem = 0;
unsigned int l0Count = 0;
//unsigned int l1Count = 0;
//unsigned int l2Count = 0;
//unsigned int l3Count = 0;
//unsigned int l4Count = 0;
//unsigned int l5Count = 0;

const int r1 = 15;
const int r2 = 24;
const int r3 = 33;
const int r4 = 42;
const int r5 = 51;
const int r6 = 60;

const int c1 = 1;
const int c2 = 38;
const int c3 = 67;
const int c4 = 96;


int availableBytes;



// THIS IS THE LOOP THAT RUNS FOREVER
void draw(void) {
// graphic commands to redraw the complete screen should be placed here




u8g.setFont(u8g_font_4x6);
//u8g.setFont(u8g_font_osb21);
// numbers for u8g.drawStr(rightPixels, downPixels)

// go down every 10 pixels for the List
u8g.drawStr( 30, 6, "Titan Rover Sys");
u8g.drawLine(1, 8, 124, 8);
u8g.drawLine(65, 8, 65, 60);



u8g.drawStr( c1, r1, "Heading:");
u8g.drawStr( c2, r1, line0);

u8g.drawStr( c1, r2, "Pitch:");
u8g.drawStr( c2, r2, line1);

u8g.drawStr( c1, r3, "Roll:");
u8g.drawStr( c2, r3, line2);

u8g.drawStr( c1, r4, "MagCal:");
u8g.drawStr( c2, r4, line3);

u8g.drawStr( c1, r5, "downLD:");
u8g.drawStr( c2, r5, line4);

u8g.drawStr( c1, r6, "upLD:");
u8g.drawStr( c2, r6, line5);


//u8g.drawStr( 67, 24, "upLD:");
//u8g.drawStr( 95, 24, line5);

//u8g.drawStr( 66, 15, "ip:");
u8g.drawStr( 72, 15, line6);

//Symbols of online or offline:
u8g.setFont(u8g_font_cursor);
// 'x' is the symbol for a skull
//u8g.drawStr( 56, 14, skull);
// 'F' is a solid circle
//u8g.drawStr( 56, 24, solidCircle);
//u8g.drawStr( 56, 32, starShipEnterprise);
//u8g.setFont(u8g_font_4x6);

//rxData.flush();

}


void setup(void) {
//SoftwareSerial setup
rxData.begin(9600);

// setup LED for blink on reading rxData
pinMode(LED_BUILTIN, OUTPUT);

// for a loopback test
// Serial.begin(9600);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for native USB port only
// }

//if(rxData.available()) {
// serialData = rxData.read();
//}

// flip screen, if required
// u8g.setRot180();

// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);

// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}

//pinMode(8, OUTPUT);
}

void loop(void) {


// picture loop
u8g.firstPage();
do {



availableBytes = rxData.available();
if(availableBytes) {
for(int j=0;j<availableBytes;++j) {
c = rxData.read();
dataHold[j] = c;
}
delay(1);
}
for(int i=0;i<6;++i) line0[i] = dataHold[i];
for(int i=6,j=0;i<12;++i,++j) line1[j] = dataHold[i];
for(int i=12,j=0;i<18;++i,++j) line2[j] = dataHold[i];
for(int i=18,j=0;i<24;++i,++j) line3[j] = dataHold[i];
for(int i=24,j=0;i<30;++i,++j) line4[j] = dataHold[i];
for(int i=30,j=0;i<36;++i,++j) line5[j] = dataHold[i];

for(int i=36,j=0;i<50;++i,++j) line6[j] = dataHold[i];
delay(10);
rxData.flush();
//rxData.flush();
//if(dataHold != "") {
// for(int i=0;i<5; ++i) line0[i] = dataHold[i];
//for(int i=5;i<11; ++i) line1[i] = dataHold[i];
//}


//availableBytes = 0;


//Serial.write(line0);
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
//delay(2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# U8glib

A graphics library with support for many different monochrome displays.

![nhd_oled180.jpg](https://github.com/olikraus/u8glib/wiki/otherpic/nhd_oled180.jpg) ![dogs102_180.jpg](https://github.com/olikraus/u8glib/wiki/otherpic/dogs102_180.jpg)

Left: NHD-2.7-12864 OLED (SSD1325), right: EA DOGS102 LCD (UC1701)

* [Gallery](https://github.com/olikraus/u8glib/wiki/gallery)
* [Bintray](https://bintray.com/olikraus/u8glib) download links:
* [U8glib for Arduino](https://bintray.com/olikraus/u8glib/Arduino)
* [U8glib for AVR](https://bintray.com/olikraus/u8glib/AVR)
* [U8glib for ARM](https://bintray.com/olikraus/u8glib/ARM)
* Converter for BDF fonts: [bdf2u8g_101.exe on google drive](https://drive.google.com/folderview?id=0B5b6Dv0wCeCRLWJkYTh2TUlYVDg&usp=sharing).
* Supported environments:
* [Arduino (ATMEGA and ARM)](http://www.arduino.cc/)
* [AVR (ATMEGA)](https://github.com/olikraus/u8glib/wiki/avr)
* [ARM (with example for LPC1114)](https://github.com/olikraus/u8glib/wiki/lpc1114)
* Library for graphic LCDs and OLEDs
* [U8glib documentation and tutorials](https://github.com/olikraus/u8glib/wiki)
* Graphical user interface library (GUI) available: [M2tklib](http://code.google.com/p/m2tklib/)
* COM interfaces: Software SPI, Hardware SPI, 8Bit parallel
* Large number of [fonts](https://github.com/olikraus/u8glib/wiki/fontsize)
* Monospaced and proportional fonts
* Mouse-Cursor support
* Landscape and portrait mode
* Many supported [devices](https://github.com/olikraus/u8glib/wiki/device) (SSD1325, ST7565, ST7920, UC1608, UC1610, UC1701, PCD8544, PCF8812, KS0108, LC7981, SBN1661, SSD1306, SH1106, T6963, LD7032)
* Well-defined interface to the device subsystem

0 comments on commit 60959cc

Please sign in to comment.