Oscilloscope for Arduino and 4D graphics controller oled screen
//////////////////////////////////////////////////////////////////////////////
// Basic Oscilloscope for the Arduino and
// 4D graphics controller based Oled screen
//
// Based on a template for the GOLDELOX-SGC Processor by
// Paul J Karlik <-Thank him for finally writing a library for the screen
// Cubtastic71@gmail.com
//
// The <Oled.h> library is available at:
// http://code.google.com/p/arduino-oled/
//
//////////////////////////////////////////////////////////////////////////////
#include <Oled.h>
#include <string.h>
#include <Wire.h>
// Int an Define the Base Vars and Params ////////////////////////////
OLED myOLED(7,8,2500,57600);
int color=0;
int color2=12;
int color3=36;
int tick = 0;
int trigger = 0;
int signal[5];
int x = 0;
int y = 0;
int px = 96;
int py = 0;
int sigtol = analogRead(A1);
// Set Up Function ///////////////////////////////////////////////////
void setup(){
Serial.begin(57600);
pinMode(10, OUTPUT);
digitalWrite(10,HIGH);
myOLED.Init();
myOLED.Clear();
color = myOLED.get16bitRGB(25,25,25);
color3 = myOLED.get16bitRGB(0,255,0);
color2 = myOLED.get16bitRGB(0,0,0);
}
// Main Program Loop ////////////////////////////////////////////////
void loop(){
//// This ‘while loop’ draws one frame of the graph
while (x <= 96) {
x++;
myOLED.DrawLine(px, py, x, y, color);
px = x;
py = y;
y=(((analogRead(A0)) / 16));
}
// This ‘analogRead()’ and ‘while loop’ allow the device to wait
// for an increasing slope from the Attack of the incoming signal
signal[4] = analogRead(A0);
while ((signal[3] - signal[4]) <= sigtol) {
sigtol = analogRead(A1); //analogRead(A1) reads a 1k pot connected to pin A1
delay(1); //to use as a 1 to 1 threshold for the trigger
signal[4] = analogRead(A0);
delay(1);
delay(int(analogRead(A2)/200));//The slope of the threshold for the trigger with a 1k pot to pin A2
signal[3] = analogRead(A0);
delay(1);
//if you have cut and pasted this from my website, you may have to retype the //following command manually, because of character translation
myOLED.DrawText(1,1,0,”hold”,color3);
}
//This sets origin points for the new frame and clears the screen by drawing a rectangle
x=0;
px = 0;
myOLED.DrawRectangle(0,0,96,64,color2);
}