Commits

jorodeo committed 5d760eb

Rearranged directories. Moved SerialLCD dependency to iorodeo_arduino_libs.

  • Participants
  • Parent commits 583f36e

Comments (0)

Files changed (6)

lcd_photogate_v2/SerialLCD.cpp

-#include "SerialLCD.h"
-
-SerialLCD::SerialLCD() {
-}
-
-SerialLCD::SerialLCD(Print &port) {
-    setPort(port);
-}
-
-void SerialLCD::setPort(Print &port) {
-    _portPtr = &port;
-}
-
-void SerialLCD::clearScreen(void) {
-    // Clear the LCD display sets x and y offsets to 0,0
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x00,BYTE);
-}
-
-void SerialLCD::print(char *data) {
-    // Print data to the LCD
-    _portPtr -> print(data);
-}
-
-void SerialLCD::print(char *data, byte x, byte y) {
-    // Print data at position given by x and y.
-    setPos(x,y);
-    print(data);
-}
-
-void SerialLCD::setBrightness(byte value) {
-    // Sets the LCD backlight brightness - adjusts duty cycle.
-    // value should be between 0 and 100.
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x02,BYTE);
-    _portPtr -> print(value,BYTE);
-}
-
-void SerialLCD::setX(byte x) {
-    // Set the x coordinate for where the next character will be drawn
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x18,BYTE);
-    _portPtr -> print(x,BYTE);
-}
-
-void SerialLCD::setY(byte y) {
-    // Set the y coordinate for where the next character will be drawn
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x19,BYTE);
-    _portPtr -> print(y,BYTE);
-}
-
-void SerialLCD::setPos(byte x, byte y) {
-    // Set x and y coordinates for where next character will be drawn
-    setX(x);
-    setY(y);
-}
-
-void SerialLCD::setPixel(byte x, byte y, byte state) {
-    // Set pixel and coordinate x,y to value given by state.
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x10,BYTE);
-    _portPtr -> print(x,BYTE);
-    _portPtr -> print(y,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawLine(
-        byte startX, 
-        byte startY, 
-        byte endX, 
-        byte endY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x0C,BYTE);
-    _portPtr -> print(startX,BYTE);
-    _portPtr -> print(startY,BYTE);
-    _portPtr -> print(endX,BYTE);
-    _portPtr -> print(endY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawBox(
-        byte topLeftX, 
-        byte topLeftY, 
-        byte bottomRightX, 
-        byte bottomRightY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x0F,BYTE);
-    _portPtr -> print(topLeftX,BYTE);
-    _portPtr -> print(topLeftY,BYTE);
-    _portPtr -> print(bottomRightX,BYTE);
-    _portPtr -> print(bottomRightY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawCircle(
-        byte startX, 
-        byte startY, 
-        byte radius, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x03,BYTE);
-    _portPtr -> print(startX,BYTE);
-    _portPtr -> print(startY,BYTE);
-    _portPtr -> print(radius,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawFilledBox(
-        byte topLeftX, 
-        byte topLeftY, 
-        byte bottomRightX, 
-        byte bottomRightY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x12,BYTE);
-    _portPtr -> print(topLeftX,BYTE);
-    _portPtr -> print(topLeftY,BYTE);
-    _portPtr -> print(bottomRightX,BYTE);
-    _portPtr -> print(bottomRightY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::toggleAuxFont() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x08,BYTE);
-}
-
-void SerialLCD::toggleRevMode() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x14,BYTE);
-}
-
-void SerialLCD::toggleSplash() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x15,BYTE);
-}
-

lcd_photogate_v2/SerialLCD.h

-#ifndef _SERIAL_LCD_H_
-#define _SERIAL_LCD_H_
-#include "WProgram.h"
-
-
-class SerialLCD {
-    private:
-        Print *_portPtr;
-    public:
-        SerialLCD();
-        SerialLCD(Print &port);
-        void setPort(Print &port);
-        void clearScreen(void);
-        void setBrightness(byte value);
-        void print(char *data);
-        void print(char *data, byte x, byte y);
-        void setX(byte x);
-        void setY(byte y);
-        void setPos(byte x, byte y);
-        void setPixel(byte x, byte y, byte state);
-        void drawLine(byte startX, byte startY, byte endX, byte endY, byte state);
-        void drawBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state);
-        void drawCircle(byte startX, byte startY, byte radius, byte state);
-        void drawFilledBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state);
-        void toggleAuxFont();
-        void toggleRevMode(); 
-        void toggleSplash();
-};
-
-#endif

lcd_photogate_v2/lcd_photogate.pde

-#include <NewSoftSerial.h>
-#include "lcd_photogate.h"
-#include "SerialLCD.h"
-#include "Sensor.h"
-#include "DisplayHandler.h"
-#include "util/atomic.h"
-
-NewSoftSerial softSerial(7,6);
-DisplayHandler display(softSerial);
-Sensor photogate;
-
-void setup() {
-    softSerial.begin(115200);
-    delay(2500);
-    display.init();
-    display.showSplashScreen();
-    timerInit();
-}
-
-void loop() {
-    uint16_t period;
-    uint16_t currValue;
-
-    ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
-        //currValue = photogate.getCurrValue();
-        currValue = photogate.getMinValueInBuf();
-        period = photogate.getPeriod();
-    }
-
-    // Update display
-    display.setBrightness();
-    display.updatePeriodText(period);
-    display.updateTracePlot(currValue);
-    delay(LOOP_DELAY);
-}
-
-ISR(TIMER2_OVF_vect) {
-    // Timer 2 overflow interrupt service routine. Take photogate 
-    // sensor readings.
-    photogate.update();
-}
-
-void timerInit(void) {
-    // Initialize timer 2 - 1kHz overflow for reading photogate 
-    TCCR2A = TIMER_TCCR2A;
-    TCCR2B = TIMER_TCCR2B;
-    OCR2A = TIMER_OCR2A;
-    // Timer 2 overflow interrupt enable 
-    TIMSK2 |= (1<<TOIE2) | (0<<OCIE2A);
-    TCNT2 = 0;
-}
-

lcd_photogate_v2/lcd_photogate_v2.pde

+#include <NewSoftSerial.h>
+#include "lcd_photogate.h"
+#include "SerialLCD.h"
+#include "Sensor.h"
+#include "DisplayHandler.h"
+#include "util/atomic.h"
+
+NewSoftSerial softSerial(7,6);
+DisplayHandler display(softSerial);
+Sensor photogate;
+
+void setup() {
+    softSerial.begin(115200);
+    delay(2500);
+    display.init();
+    display.showSplashScreen();
+    timerInit();
+}
+
+void loop() {
+    uint16_t period;
+    uint16_t currValue;
+
+    ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
+        //currValue = photogate.getCurrValue();
+        currValue = photogate.getMinValueInBuf();
+        period = photogate.getPeriod();
+    }
+
+    // Update display
+    display.setBrightness();
+    display.updatePeriodText(period);
+    display.updateTracePlot(currValue);
+    delay(LOOP_DELAY);
+}
+
+ISR(TIMER2_OVF_vect) {
+    // Timer 2 overflow interrupt service routine. Take photogate 
+    // sensor readings.
+    photogate.update();
+}
+
+void timerInit(void) {
+    // Initialize timer 2 - 1kHz overflow for reading photogate 
+    TCCR2A = TIMER_TCCR2A;
+    TCCR2B = TIMER_TCCR2B;
+    OCR2A = TIMER_OCR2A;
+    // Timer 2 overflow interrupt enable 
+    TIMSK2 |= (1<<TOIE2) | (0<<OCIE2A);
+    TCNT2 = 0;
+}
+

lcd_photogate_v3/SerialLCD.cpp

-#include "SerialLCD.h"
-
-SerialLCD::SerialLCD() {
-}
-
-SerialLCD::SerialLCD(Print &port) {
-    setPort(port);
-}
-
-void SerialLCD::setPort(Print &port) {
-    _portPtr = &port;
-}
-
-void SerialLCD::clearScreen(void) {
-    // Clear the LCD display sets x and y offsets to 0,0
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x00,BYTE);
-}
-
-void SerialLCD::print(char *data) {
-    // Print data to the LCD
-    _portPtr -> print(data);
-}
-
-void SerialLCD::print(char *data, byte x, byte y) {
-    // Print data at position given by x and y.
-    setPos(x,y);
-    print(data);
-}
-
-void SerialLCD::setBrightness(byte value) {
-    // Sets the LCD backlight brightness - adjusts duty cycle.
-    // value should be between 0 and 100.
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x02,BYTE);
-    _portPtr -> print(value,BYTE);
-}
-
-void SerialLCD::setX(byte x) {
-    // Set the x coordinate for where the next character will be drawn
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x18,BYTE);
-    _portPtr -> print(x,BYTE);
-}
-
-void SerialLCD::setY(byte y) {
-    // Set the y coordinate for where the next character will be drawn
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x19,BYTE);
-    _portPtr -> print(y,BYTE);
-}
-
-void SerialLCD::setPos(byte x, byte y) {
-    // Set x and y coordinates for where next character will be drawn
-    setX(x);
-    setY(y);
-}
-
-void SerialLCD::setPixel(byte x, byte y, byte state) {
-    // Set pixel and coordinate x,y to value given by state.
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x10,BYTE);
-    _portPtr -> print(x,BYTE);
-    _portPtr -> print(y,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawLine(
-        byte startX, 
-        byte startY, 
-        byte endX, 
-        byte endY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x0C,BYTE);
-    _portPtr -> print(startX,BYTE);
-    _portPtr -> print(startY,BYTE);
-    _portPtr -> print(endX,BYTE);
-    _portPtr -> print(endY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawBox(
-        byte topLeftX, 
-        byte topLeftY, 
-        byte bottomRightX, 
-        byte bottomRightY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x0F,BYTE);
-    _portPtr -> print(topLeftX,BYTE);
-    _portPtr -> print(topLeftY,BYTE);
-    _portPtr -> print(bottomRightX,BYTE);
-    _portPtr -> print(bottomRightY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawCircle(
-        byte startX, 
-        byte startY, 
-        byte radius, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x03,BYTE);
-    _portPtr -> print(startX,BYTE);
-    _portPtr -> print(startY,BYTE);
-    _portPtr -> print(radius,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::drawFilledBox(
-        byte topLeftX, 
-        byte topLeftY, 
-        byte bottomRightX, 
-        byte bottomRightY, 
-        byte state
-        )
-{
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x12,BYTE);
-    _portPtr -> print(topLeftX,BYTE);
-    _portPtr -> print(topLeftY,BYTE);
-    _portPtr -> print(bottomRightX,BYTE);
-    _portPtr -> print(bottomRightY,BYTE);
-    _portPtr -> print(state,BYTE);
-}
-
-void SerialLCD::toggleAuxFont() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x08,BYTE);
-}
-
-void SerialLCD::toggleRevMode() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x14,BYTE);
-}
-
-void SerialLCD::toggleSplash() {
-    _portPtr -> print(0x7C,BYTE);
-    _portPtr -> print(0x15,BYTE);
-}
-

lcd_photogate_v3/SerialLCD.h

-#ifndef _SERIAL_LCD_H_
-#define _SERIAL_LCD_H_
-#include "WProgram.h"
-
-
-class SerialLCD {
-    private:
-        Print *_portPtr;
-    public:
-        SerialLCD();
-        SerialLCD(Print &port);
-        void setPort(Print &port);
-        void clearScreen(void);
-        void setBrightness(byte value);
-        void print(char *data);
-        void print(char *data, byte x, byte y);
-        void setX(byte x);
-        void setY(byte y);
-        void setPos(byte x, byte y);
-        void setPixel(byte x, byte y, byte state);
-        void drawLine(byte startX, byte startY, byte endX, byte endY, byte state);
-        void drawBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state);
-        void drawCircle(byte startX, byte startY, byte radius, byte state);
-        void drawFilledBox(byte topLeftX, byte topLeftY, byte bottomRightX, byte bottomRightY, byte state);
-        void toggleAuxFont();
-        void toggleRevMode(); 
-        void toggleSplash();
-};
-
-#endif