+++ Additional Codework
This commit is contained in:
parent
803027cbb4
commit
3c3c628b61
38 changed files with 1645 additions and 28 deletions
1
source/Concept/Framework/modules/output/display.c
Executable file
1
source/Concept/Framework/modules/output/display.c
Executable file
|
@ -0,0 +1 @@
|
|||
#include "display.h"
|
198
source/Concept/Framework/modules/output/display.h
Executable file
198
source/Concept/Framework/modules/output/display.h
Executable file
|
@ -0,0 +1,198 @@
|
|||
#ifndef _DISPLAY_H
|
||||
#define _DISPLAY_H
|
||||
|
||||
#include "../../stdafx.h"
|
||||
|
||||
class Display : public IO_Module
|
||||
{
|
||||
public:
|
||||
Display()
|
||||
{
|
||||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->cursorVisible = false;
|
||||
this->illuminationEnabled = true;
|
||||
this->commandClear = 0;
|
||||
this->commandReturnCursor = 0;
|
||||
this->commandNewLine = 0;
|
||||
this->commandSetting = 0;
|
||||
this->settingCursorVisible = 0;
|
||||
this->settingIllumination = 0;
|
||||
this->settingCursorPosition = 0;
|
||||
}
|
||||
|
||||
Display(uint32 displayId)
|
||||
{
|
||||
this->parent = NULL;
|
||||
this->moduleId = displayId;
|
||||
this->cursorVisible = false;
|
||||
this->illuminationEnabled = true;
|
||||
|
||||
switch(displayId)
|
||||
{
|
||||
case IO_DISPLAY_MAIN:
|
||||
this->commandClear = 12;
|
||||
this->commandReturnCursor = 13;
|
||||
this->commandNewLine = 10;
|
||||
this->commandSetting = 27;
|
||||
this->settingCursorVisible = 67;
|
||||
this->settingIllumination = 76;
|
||||
this->settingCursorPosition = 79;
|
||||
msleep(100);
|
||||
uart1_init(103);//9600 BAUD at 16MHz Atmel
|
||||
msleep(100);
|
||||
break;
|
||||
default:
|
||||
this->commandClear = 0;
|
||||
this->commandReturnCursor = 0;
|
||||
this->commandNewLine = 0;
|
||||
this->commandSetting = 0;
|
||||
this->settingCursorVisible = 0;
|
||||
this->settingIllumination = 0;
|
||||
this->settingCursorPosition = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool cursorVisible;
|
||||
bool illuminationEnabled;
|
||||
//Commands
|
||||
uint8 commandClear;
|
||||
uint8 commandReturnCursor;
|
||||
uint8 commandNewLine;
|
||||
uint8 commandSetting;
|
||||
//Settings
|
||||
uint8 settingCursorVisible;
|
||||
uint8 settingIllumination;
|
||||
uint8 settingCursorPosition;
|
||||
|
||||
void SendCommand(uint8 newCommand)
|
||||
{
|
||||
switch(moduleId)
|
||||
{
|
||||
case IO_DISPLAY_MAIN:
|
||||
uart1_putc(newCommand);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
void Print(char* newString)
|
||||
{
|
||||
switch(moduleId)
|
||||
{
|
||||
case IO_DISPLAY_MAIN:
|
||||
uart1_puts(newString);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Print(int32 newInteger)
|
||||
{
|
||||
char buffer[12];
|
||||
ltoa(newInteger, buffer, 10);
|
||||
Print(buffer);
|
||||
}
|
||||
|
||||
void PrintFloat(float newFloat)
|
||||
{
|
||||
Print((int32)(newFloat));
|
||||
Print(".");
|
||||
Print(abs((uint32)(newFloat - float((int32)(newFloat)) * 100000)));
|
||||
}
|
||||
|
||||
void Print(char* newString, uint8 xPos, uint8 yPos)
|
||||
{
|
||||
SetCursorPosition(xPos, yPos);
|
||||
Print(newString);
|
||||
}
|
||||
|
||||
void Print(int32 newInteger, uint8 xPos, uint8 yPos)
|
||||
{
|
||||
SetCursorPosition(xPos, yPos);
|
||||
Print(newInteger);
|
||||
}
|
||||
|
||||
void PrintFloat(float newFloat, uint8 xPos, uint8 yPos)
|
||||
{
|
||||
SetCursorPosition(xPos, yPos);
|
||||
PrintFloat(newFloat);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
SendCommand(commandClear);
|
||||
}
|
||||
|
||||
void ReturnCursor()
|
||||
{
|
||||
SendCommand(commandReturnCursor);
|
||||
}
|
||||
|
||||
void NewLine()
|
||||
{
|
||||
SendCommand(commandNewLine);
|
||||
}
|
||||
|
||||
bool GetCursorVisible()
|
||||
{
|
||||
return cursorVisible;
|
||||
}
|
||||
|
||||
void SetCursorVisible(bool newStatus)
|
||||
{
|
||||
cursorVisible = newStatus;
|
||||
|
||||
SendCommand(commandSetting);
|
||||
SendCommand(settingCursorVisible);
|
||||
|
||||
if(cursorVisible)
|
||||
{
|
||||
SendCommand(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendCommand(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool GetLightingEnabled()
|
||||
{
|
||||
return illuminationEnabled;
|
||||
}
|
||||
|
||||
void SetLightingEnabled(bool newStatus)
|
||||
{
|
||||
illuminationEnabled = newStatus;
|
||||
|
||||
SendCommand(commandSetting);
|
||||
SendCommand(settingIllumination);
|
||||
|
||||
if(illuminationEnabled)
|
||||
{
|
||||
SendCommand(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendCommand(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCursorPosition(uint8 newX, uint8 newY)
|
||||
{
|
||||
if(!newX || newX > 20) return;
|
||||
if(!newY || newY > 4) return;
|
||||
|
||||
SendCommand(commandSetting);
|
||||
SendCommand(settingCursorPosition);
|
||||
SendCommand(newX);
|
||||
SendCommand(newY);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/Framework/modules/output/dribbler.c
Executable file
1
source/Concept/Framework/modules/output/dribbler.c
Executable file
|
@ -0,0 +1 @@
|
|||
#include "dribbler.h"
|
118
source/Concept/Framework/modules/output/dribbler.h
Executable file
118
source/Concept/Framework/modules/output/dribbler.h
Executable file
|
@ -0,0 +1,118 @@
|
|||
#ifndef _DRIBBLER_H
|
||||
#define _DRIBBLER_H
|
||||
|
||||
#include "../../stdafx.h"
|
||||
|
||||
class Dribbler : public IO_Module
|
||||
{
|
||||
public:
|
||||
Dribbler()
|
||||
{
|
||||
this->enabled = false;
|
||||
this->curSpeed = 0;
|
||||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->hardwarePort = NULL;
|
||||
this->portPower = NULL;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
this->pinPower = 0;
|
||||
}
|
||||
|
||||
Dribbler(uint32 dribblerId)
|
||||
{
|
||||
this->enabled = false;
|
||||
this->curSpeed = 1.0f;
|
||||
this->parent = NULL;
|
||||
this->moduleId = dribblerId;
|
||||
|
||||
switch(dribblerId)
|
||||
{
|
||||
case IO_DRIBBLER_MAIN:
|
||||
this->hardwarePort = &PORTD;
|
||||
this->portPower = &PORTA;
|
||||
this->pinForward = (1 << 6);
|
||||
this->pinReverse = (1 << 7);
|
||||
this->pinPower = (1 << 5);
|
||||
break;
|
||||
default:
|
||||
this->hardwarePort = NULL;
|
||||
this->portPower = NULL;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
this->pinPower = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateDirection();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool enabled;
|
||||
float curSpeed;
|
||||
|
||||
//Hardware
|
||||
volatile uint8* hardwarePort;
|
||||
volatile uint8* portPower;
|
||||
uint8 pinForward;
|
||||
uint8 pinReverse;
|
||||
uint8 pinPower;
|
||||
|
||||
void UpdateDirection()
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
if(curSpeed > 0)
|
||||
{
|
||||
*hardwarePort |= pinForward;
|
||||
*hardwarePort &= ~pinReverse;
|
||||
}
|
||||
else if(curSpeed < 0)
|
||||
{
|
||||
*hardwarePort |= pinReverse;
|
||||
*hardwarePort &= ~pinForward;
|
||||
}
|
||||
else
|
||||
{
|
||||
*hardwarePort |= pinForward;
|
||||
*hardwarePort |= pinReverse;
|
||||
}
|
||||
|
||||
*portPower |= pinPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
*hardwarePort &= ~pinForward;
|
||||
*hardwarePort &= ~pinReverse;
|
||||
|
||||
*portPower &= ~pinPower;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
float GetSpeed()
|
||||
{
|
||||
return curSpeed;
|
||||
}
|
||||
|
||||
void SetSpeed(float newSpeed)
|
||||
{
|
||||
curSpeed = newSpeed;
|
||||
|
||||
UpdateDirection();
|
||||
}
|
||||
|
||||
bool GetEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool newStatus)
|
||||
{
|
||||
enabled = newStatus;
|
||||
|
||||
UpdateDirection();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/Framework/modules/output/engine.c
Executable file
1
source/Concept/Framework/modules/output/engine.c
Executable file
|
@ -0,0 +1 @@
|
|||
#include "engine.h"
|
124
source/Concept/Framework/modules/output/engine.h
Executable file
124
source/Concept/Framework/modules/output/engine.h
Executable file
|
@ -0,0 +1,124 @@
|
|||
#ifndef _ENGINE_H
|
||||
#define _ENGINE_H
|
||||
|
||||
#include "../../stdafx.h"
|
||||
|
||||
class Engine : public IO_Module
|
||||
{
|
||||
public:
|
||||
Engine()
|
||||
{
|
||||
this->enabled = false;
|
||||
this->curSpeed = 0;
|
||||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->hardwarePort = NULL;
|
||||
this->pwmSpeed = NULL;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
}
|
||||
|
||||
Engine(uint32 engineId)
|
||||
{
|
||||
this->enabled = false;
|
||||
this->curSpeed = 0;
|
||||
this->parent = NULL;
|
||||
this->moduleId = engineId;
|
||||
|
||||
switch(engineId)
|
||||
{
|
||||
case IO_ENGINE_DRIVE_LEFT:
|
||||
this->hardwarePort = &PORTB;
|
||||
this->pwmSpeed = &OCR1A;
|
||||
this->pinForward = (1 << 0);
|
||||
this->pinReverse = (1 << 1);
|
||||
break;
|
||||
case IO_ENGINE_DRIVE_BACK:
|
||||
this->hardwarePort = &PORTB;
|
||||
this->pwmSpeed = &OCR1B;
|
||||
this->pinForward = (1 << 2);
|
||||
this->pinReverse = (1 << 3);
|
||||
break;
|
||||
case IO_ENGINE_DRIVE_RIGHT:
|
||||
this->hardwarePort = &PORTD;
|
||||
this->pwmSpeed = &OCR3A;
|
||||
this->pinForward = (1 << 5);
|
||||
this->pinReverse = (1 << 4);
|
||||
break;
|
||||
default:
|
||||
this->hardwarePort = NULL;
|
||||
this->pwmSpeed = NULL;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
*this->pwmSpeed = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool enabled;
|
||||
float curSpeed;
|
||||
|
||||
//Hardware
|
||||
volatile uint8* hardwarePort;
|
||||
volatile uint16* pwmSpeed;
|
||||
uint8 pinForward;
|
||||
uint8 pinReverse;
|
||||
|
||||
void UpdateDirection()
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
if(curSpeed > 0)
|
||||
{
|
||||
*hardwarePort |= pinForward;
|
||||
*hardwarePort &= ~pinReverse;
|
||||
}
|
||||
else if(curSpeed < 0)
|
||||
{
|
||||
*hardwarePort |= pinReverse;
|
||||
*hardwarePort &= ~pinForward;
|
||||
}
|
||||
else
|
||||
{
|
||||
*hardwarePort |= pinForward;
|
||||
*hardwarePort |= pinReverse;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*hardwarePort &= ~pinForward;
|
||||
*hardwarePort &= ~pinReverse;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
float GetSpeed()
|
||||
{
|
||||
return curSpeed;
|
||||
}
|
||||
|
||||
void SetSpeed(float newSpeed)
|
||||
{
|
||||
curSpeed = newSpeed;
|
||||
|
||||
*pwmSpeed = (abs((int16)(newSpeed / SPEED_PER_PWM)));
|
||||
|
||||
UpdateDirection();
|
||||
}
|
||||
|
||||
bool GetEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool newStatus)
|
||||
{
|
||||
enabled = newStatus;
|
||||
|
||||
UpdateDirection();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/Framework/modules/output/kicker.c
Executable file
1
source/Concept/Framework/modules/output/kicker.c
Executable file
|
@ -0,0 +1 @@
|
|||
#include "kicker.h"
|
84
source/Concept/Framework/modules/output/kicker.h
Executable file
84
source/Concept/Framework/modules/output/kicker.h
Executable file
|
@ -0,0 +1,84 @@
|
|||
#ifndef _KICKER_H
|
||||
#define _KICKER_H
|
||||
|
||||
#include "../../stdafx.h"
|
||||
|
||||
class Kicker : public IO_Module
|
||||
{
|
||||
public:
|
||||
Kicker()
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->portPower = NULL;
|
||||
this->portForward = NULL;
|
||||
this->portReverse = NULL;
|
||||
this->pinPower = 0;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
}
|
||||
|
||||
Kicker(uint32 kickerId)
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
this->moduleId = kickerId;
|
||||
|
||||
switch(kickerId)
|
||||
{
|
||||
case IO_KICKER_MAIN:
|
||||
this->portPower = &PORTG;
|
||||
this->portForward = &PORTA;
|
||||
this->portReverse = &PORTE;
|
||||
this->pinPower = (1 << 3);
|
||||
this->pinForward = (1 << 2);
|
||||
this->pinReverse = (1 << 6);
|
||||
break;
|
||||
default:
|
||||
this->portPower = NULL;
|
||||
this->portForward = NULL;
|
||||
this->portReverse = NULL;
|
||||
this->pinPower = 0;
|
||||
this->pinForward = 0;
|
||||
this->pinReverse = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
*this->portForward |= this->pinForward;
|
||||
*this->portReverse &= ~this->pinReverse;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool enabled;
|
||||
|
||||
//Hardware
|
||||
volatile uint8* portPower;
|
||||
volatile uint8* portForward;
|
||||
volatile uint8* portReverse;
|
||||
uint8 pinPower;
|
||||
uint8 pinForward;
|
||||
uint8 pinReverse;
|
||||
|
||||
public:
|
||||
bool GetEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool newStatus)
|
||||
{
|
||||
enabled = newStatus;
|
||||
|
||||
if(enabled)
|
||||
{
|
||||
*portPower |= pinPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
*portPower &= ~pinPower;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
1
source/Concept/Framework/modules/output/led.c
Executable file
1
source/Concept/Framework/modules/output/led.c
Executable file
|
@ -0,0 +1 @@
|
|||
#include "led.h"
|
65
source/Concept/Framework/modules/output/led.h
Executable file
65
source/Concept/Framework/modules/output/led.h
Executable file
|
@ -0,0 +1,65 @@
|
|||
#ifndef _LED_H
|
||||
#define _LED_H
|
||||
|
||||
#include "../../stdafx.h"
|
||||
|
||||
class Led : public IO_Module
|
||||
{
|
||||
public:
|
||||
Led()
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
this->moduleId = 0;
|
||||
this->hardwarePort = NULL;
|
||||
this->pinPower = 0;
|
||||
}
|
||||
|
||||
Led(uint32 ledId)
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
this->moduleId = ledId;
|
||||
|
||||
switch(ledId)
|
||||
{
|
||||
case IO_LED_MAIN:
|
||||
this->hardwarePort = &PORTB;
|
||||
this->pinPower = (1 << 1);
|
||||
break;
|
||||
default:
|
||||
this->hardwarePort = NULL;
|
||||
this->pinPower = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool enabled;
|
||||
|
||||
//Hardware
|
||||
volatile uint8* hardwarePort;
|
||||
uint8 pinPower;
|
||||
|
||||
public:
|
||||
bool GetEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool newStatus)
|
||||
{
|
||||
enabled = newStatus;
|
||||
|
||||
if(enabled)
|
||||
{
|
||||
*hardwarePort &= ~pinPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
*hardwarePort |= pinPower;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
Reference in a new issue