began working on actual code for parsing values from uart
not working yet!
This commit is contained in:
parent
7352839d1e
commit
1a7c59bed8
|
@ -2,21 +2,16 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="9fad4545-a424-4a82-86dc-76602cf3eef3" name="Default" comment="">
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/main.c" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/main.h" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/uart.c" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/uart.h" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/utils.c" />
|
||||
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/displayboard/src/utils.h" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/displayboard/Makefile" afterPath="$PROJECT_DIR$/displayboard/Makefile" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/displayboard/src/main.c" afterPath="$PROJECT_DIR$/displayboard/src/main.c" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
</list>
|
||||
<ignored path="bikegenerator.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<file path="/Makefile" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032328243" ignored="false" />
|
||||
<file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371166540202" ignored="false" />
|
||||
<file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371163595702" ignored="false" />
|
||||
<file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371215015916" ignored="false" />
|
||||
<file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371210598726" ignored="false" />
|
||||
<file path="/uart.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371164805619" ignored="false" />
|
||||
<file path="/a.java" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371206947114" ignored="false" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -31,6 +26,7 @@
|
|||
<disable_hints />
|
||||
</component>
|
||||
<component name="DebuggerManager">
|
||||
<ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
|
||||
<breakpoint_any default_suspend_policy="SuspendAll" default_condition_enabled="true">
|
||||
<breakpoint>
|
||||
<option name="NOTIFY_CAUGHT" value="true" />
|
||||
|
@ -67,7 +63,6 @@
|
|||
<option name="LOG_MESSAGE" value="" />
|
||||
</breakpoint>
|
||||
</breakpoint_any>
|
||||
<ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
|
||||
<breakpoint_rules />
|
||||
<ui_properties />
|
||||
</component>
|
||||
|
@ -77,19 +72,28 @@
|
|||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="main.h" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.h">
|
||||
<file leaf-file-name="main.c" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="20" column="28" selection-start="506" selection-end="522" vertical-scroll-proportion="0.0">
|
||||
<state line="135" column="8" selection-start="3155" selection-end="3155" vertical-scroll-proportion="1.2080537">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="main.c" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.c">
|
||||
<file leaf-file-name="uart.c" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/uart.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="98" column="17" selection-start="1974" selection-end="1974" vertical-scroll-proportion="0.738255">
|
||||
<state line="479" column="0" selection-start="15703" selection-end="15703" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="main.h" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="6" column="20" selection-start="117" selection-end="125" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -118,16 +122,16 @@
|
|||
<option value="$PROJECT_DIR$/powerboard/src/adc.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/adc.c" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/uart.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/main.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/utils.c" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/utils.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/Makefile" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/utils.h" />
|
||||
<option value="$PROJECT_DIR$/displayboard/Makefile" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/main.h" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/uart.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/main.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/utils.h" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/utils.c" />
|
||||
<option value="$PROJECT_DIR$/powerboard/Makefile" />
|
||||
<option value="$PROJECT_DIR$/powerboard/src/main.c" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/uart.c" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/uart.h" />
|
||||
<option value="$PROJECT_DIR$/displayboard/src/main.c" />
|
||||
</list>
|
||||
</option>
|
||||
|
@ -138,6 +142,37 @@
|
|||
<option name="width" value="1608" />
|
||||
<option name="height" value="853" />
|
||||
</component>
|
||||
<component name="ProjectInspectionProfilesVisibleTreeState">
|
||||
<entry key="Project Default">
|
||||
<profile-state>
|
||||
<expanded-state>
|
||||
<State>
|
||||
<id />
|
||||
</State>
|
||||
<State>
|
||||
<id>CDI(Contexts and Dependency Injection) issues</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>GeneralJavaScript</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>JavaScript</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Spring Model</id>
|
||||
</State>
|
||||
<State>
|
||||
<id>Spring SecuritySpring Model</id>
|
||||
</State>
|
||||
</expanded-state>
|
||||
<selected-state>
|
||||
<State>
|
||||
<id>Abstraction issues</id>
|
||||
</State>
|
||||
</selected-state>
|
||||
</profile-state>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
|
@ -164,6 +199,7 @@
|
|||
<sortByType />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
|
@ -223,17 +259,16 @@
|
|||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="project.structure.last.edited" value="Project" />
|
||||
<property name="project.structure.last.edited" value="Modules" />
|
||||
<property name="GoToFile.includeJavaFiles" value="false" />
|
||||
<property name="project.structure.proportion" value="0.0" />
|
||||
<property name="options.splitter.main.proportions" value="0.3" />
|
||||
<property name="MemberChooser.sorted" value="false" />
|
||||
<property name="recentsLimit" value="5" />
|
||||
<property name="options.lastSelected" value="project.propCompiler" />
|
||||
<property name="options.lastSelected" value="File.Encoding" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
<property name="MemberChooser.copyJavadoc" value="false" />
|
||||
|
@ -406,7 +441,23 @@
|
|||
<created>1371166541841</created>
|
||||
<updated>1371166541841</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<task id="LOCAL-00008" summary="made a first version with 7-seg number output">
|
||||
<created>1371166559819</created>
|
||||
<updated>1371166559819</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00009" summary="minor changes, made counters 8bit">
|
||||
<created>1371206855146</created>
|
||||
<updated>1371206855146</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00010" summary="changed power to 16bit added output of relais states">
|
||||
<created>1371214968413</created>
|
||||
<updated>1371214968413</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00011" summary="removed unnecessary uart1 code">
|
||||
<created>1371215016953</created>
|
||||
<updated>1371215016953</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="12" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
|
@ -479,7 +530,7 @@
|
|||
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="false" />
|
||||
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="changed counter (bugfix) changed baudrate to 19200" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="removed unnecessary uart1 code" />
|
||||
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
|
||||
|
@ -500,6 +551,10 @@
|
|||
<MESSAGE value="bugfixes, live check on avr working for now" />
|
||||
<MESSAGE value="changed resistor values for 7-Seg removed lm371 due to lack of voltage" />
|
||||
<MESSAGE value="changed counter (bugfix) changed baudrate to 19200" />
|
||||
<MESSAGE value="made a first version with 7-seg number output" />
|
||||
<MESSAGE value="minor changes, made counters 8bit" />
|
||||
<MESSAGE value="changed power to 16bit added output of relais states" />
|
||||
<MESSAGE value="removed unnecessary uart1 code" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
|
@ -524,85 +579,79 @@
|
|||
<state line="80" column="76" selection-start="2948" selection-end="2948" vertical-scroll-proportion="-1.9201807" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="5" column="32" selection-start="142" selection-end="142" vertical-scroll-proportion="0.0" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/uart.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="176" column="0" selection-start="6326" selection-end="6326" vertical-scroll-proportion="0.7784343" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/Makefile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="62" column="28" selection-start="1637" selection-end="1637" vertical-scroll-proportion="0.3323486" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/utils.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="4" column="45" selection-start="71" selection-end="112" vertical-scroll-proportion="0.08836524" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/Makefile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="21" column="22" selection-start="465" selection-end="465" vertical-scroll-proportion="0.46391752" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/utils.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="30" column="22" selection-start="656" selection-end="673" vertical-scroll-proportion="0.66273934">
|
||||
<folding />
|
||||
</state>
|
||||
<state line="30" column="22" selection-start="656" selection-end="673" vertical-scroll-proportion="0.66273934" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/main.h">
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="31" column="36" selection-start="864" selection-end="864" vertical-scroll-proportion="0.6848306">
|
||||
<folding />
|
||||
</state>
|
||||
<state line="5" column="40" selection-start="150" selection-end="150" vertical-scroll-proportion="0.16703786" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/Makefile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="62" column="28" selection-start="1637" selection-end="1637" vertical-scroll-proportion="0.33407572" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="33" column="0" selection-start="760" selection-end="865" vertical-scroll-proportion="0.72901326">
|
||||
<state line="21" column="28" selection-start="449" selection-end="449" vertical-scroll-proportion="0.26726058" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/main.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="23" column="31" selection-start="648" selection-end="648" vertical-scroll-proportion="0.66592425">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/Makefile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="21" column="22" selection-start="465" selection-end="465" vertical-scroll-proportion="-0.70469797" />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/powerboard/src/main.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="159" column="34" selection-start="4186" selection-end="4186" vertical-scroll-proportion="0.0">
|
||||
<state line="47" column="6" selection-start="1206" selection-end="1206" vertical-scroll-proportion="-3.6577182">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="20" column="28" selection-start="506" selection-end="522" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/uart.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="141" column="11" selection-start="5298" selection-end="5298" vertical-scroll-proportion="0.5301915">
|
||||
<state line="6" column="20" selection-start="117" selection-end="125" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/uart.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="434" column="55" selection-start="14628" selection-end="14628" vertical-scroll-proportion="0.490991">
|
||||
<folding>
|
||||
<element signature="n#!!doc" expanded="true" />
|
||||
</folding>
|
||||
<state line="479" column="0" selection-start="15703" selection-end="15703" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/uart.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="141" column="11" selection-start="5298" selection-end="5298" vertical-scroll-proportion="-0.40939596">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/displayboard/src/main.c">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="98" column="17" selection-start="1974" selection-end="1974" vertical-scroll-proportion="0.738255">
|
||||
<state line="135" column="8" selection-start="3155" selection-end="3155" vertical-scroll-proportion="1.2080537">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -660,7 +709,7 @@
|
|||
</state>
|
||||
<state key="ModuleStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>powerboard</last-edited>
|
||||
<last-edited>displayboard</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
|
|
|
@ -1,30 +1,47 @@
|
|||
#include <stdlib.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <string.h>
|
||||
#include "utils.h"
|
||||
#include "main.h"
|
||||
#include "uart.h"
|
||||
|
||||
volatile uint16_t syscounter = 0;
|
||||
volatile uint16_t digitcounter = 0;
|
||||
volatile uint8_t digitbuffer[6] = { 0,0,0,0,0,0 };
|
||||
volatile uint8_t leddigitbuffer[4] = { 0,0,0,0 };
|
||||
uint8_t digit = 0;
|
||||
uint8_t digitbuffer[6] = { 0,0,0,0,0,0 };
|
||||
uint8_t leddigit = 0;
|
||||
|
||||
// values send over uart from powerboard
|
||||
uint16_t voltage = 0;
|
||||
int16_t current_in = 0;
|
||||
int16_t current_out = 0;
|
||||
uint8_t dumpsw = 0; //TODO: make bitfield
|
||||
uint8_t loadsw = 0; //TODO: make bitfield
|
||||
uint8_t gensw = 0; //TODO: make bitfield
|
||||
|
||||
uint16_t power_gen = 0;
|
||||
uint16_t power_load = 0;
|
||||
|
||||
unsigned char data_count = 0;
|
||||
unsigned char data_in[20];
|
||||
char command_in[20];
|
||||
|
||||
const uint8_t digit_translate[10] = {
|
||||
63, 6, 91, 79, 102, 109, 125, 7, 127, 111
|
||||
};
|
||||
|
||||
|
||||
void timer_init(void) {
|
||||
static void timer_init(void) {
|
||||
// clock is 8MHz
|
||||
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||
OCR1A = 125; // 1000Hz
|
||||
OCR1A = 250; // 500Hz
|
||||
TIMSK = _BV(OCIE1A);
|
||||
sei(); // enable interrupts
|
||||
}
|
||||
|
||||
void ports_init(void) {
|
||||
|
||||
static void ports_init(void) {
|
||||
// make column / digit driver pins to output
|
||||
LEDDIG_DDR |= _BV(LEDS_MID1) | _BV(LEDS_MID2) | _BV(LEDS_LOAD) | _BV(LEDS_GEN);
|
||||
SEVENSEGDIG_DDR |= _BV(DIG0) | _BV(DIG1) | _BV(DIG2) | _BV(DIG3) | _BV(DIG4) | _BV(DIG5);
|
||||
|
@ -41,15 +58,12 @@ void ports_init(void) {
|
|||
}
|
||||
|
||||
|
||||
void print_uint8(uint8_t display, uint8_t value) {
|
||||
|
||||
static void print_sevenseg(uint8_t display, uint16_t value) {
|
||||
uint8_t d[3];
|
||||
d[2] = (value % 1000 / 100 );
|
||||
d[1] = (value % 100 / 10 );
|
||||
d[0] = (value % 10);
|
||||
|
||||
|
||||
|
||||
if(display == 0) {
|
||||
for(uint8_t i = 0; i< 3; i++) {
|
||||
digitbuffer[i] = digit_translate[d[i]];
|
||||
|
@ -59,55 +73,94 @@ void print_uint8(uint8_t display, uint8_t value) {
|
|||
digitbuffer[i+3] = digit_translate[d[i]];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
ports_init();
|
||||
|
||||
timer_init();
|
||||
|
||||
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||
|
||||
uint8_t temp = 0;
|
||||
uint8_t uart_char = 0;
|
||||
|
||||
digit = 0;
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
if(digitcounter == 2) {
|
||||
digitcounter = 0;
|
||||
digit++;
|
||||
if(digit >5) digit = 0;
|
||||
|
||||
SEVENSEG_PORT = digitbuffer[digit];
|
||||
SEVENSEGDIG_PORT = _BV(digit+2);
|
||||
}
|
||||
|
||||
|
||||
if(syscounter == 200) {
|
||||
|
||||
static void receive_values_from_powerboard(void) {
|
||||
uint16_t uart_char;
|
||||
static char buffer[20];
|
||||
// send a to request data from powerboard
|
||||
uart_putc('a');
|
||||
|
||||
// input format is:
|
||||
// A$voltage,$current_in,$current_out,$power_in,$power_out,loadsw,dumpsw,gensw\n
|
||||
|
||||
uart_char = uart_getc();
|
||||
|
||||
if(uart_char != UART_NO_DATA) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
voltage = 12200;
|
||||
current_in = 1500;
|
||||
current_out = 1600;
|
||||
power_gen += 1;
|
||||
power_load += 2;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void process_command() {
|
||||
if(strstr(command_in,"a") != NULL) {
|
||||
//
|
||||
|
||||
if(strcasestr(command_in,"?") != NULL)
|
||||
print_value("goto", variable_goto);
|
||||
else
|
||||
variable_goto = parse_assignment(command_in);
|
||||
}
|
||||
else if(strcasestr(command_in,"A") != NULL){
|
||||
if(strcasestr(command_in,"?") != NULL)
|
||||
print_value("A", variable_A);
|
||||
else
|
||||
variable_A = parse_assignment(command_in);
|
||||
}
|
||||
} */
|
||||
|
||||
void work_uart(){
|
||||
unsigned int c = uart_getc();
|
||||
|
||||
if ( !(c & UART_NO_DATA) ) {
|
||||
|
||||
data_in[data_count] = c;
|
||||
|
||||
if (data_in[data_count] == '\n') { // finish reading when newline is received
|
||||
data_count = 0;
|
||||
|
||||
// copy_command
|
||||
memcpy(command_in, data_in, 20);
|
||||
// Now clear data_in, the UART can reuse it now
|
||||
memset(data_in, 0, 20);
|
||||
|
||||
//process_command();
|
||||
} else {
|
||||
data_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print_uint8(0, temp);
|
||||
print_uint8(1, temp);
|
||||
|
||||
|
||||
int main(void) {
|
||||
ports_init();
|
||||
timer_init();
|
||||
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||
|
||||
while(1) {
|
||||
|
||||
work_uart();
|
||||
|
||||
if(syscounter == 200) {
|
||||
|
||||
receive_values_from_powerboard();
|
||||
|
||||
print_sevenseg(0, power_gen);
|
||||
print_sevenseg(1, power_load);
|
||||
|
||||
syscounter = 0;
|
||||
temp++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
|
@ -116,7 +169,19 @@ int main(void) {
|
|||
// system timer
|
||||
SIGNAL(TIMER1_COMPA_vect) {
|
||||
syscounter++;
|
||||
digitcounter++;
|
||||
|
||||
// output to sevensegment and leds
|
||||
// make this here to reduce display flicker
|
||||
digit++;
|
||||
if(digit >5) digit = 0;
|
||||
leddigit++;
|
||||
if(leddigit >3) leddigit = 0;
|
||||
|
||||
SEVENSEG_PORT = digitbuffer[digit];
|
||||
SEVENSEGDIG_PORT = _BV(digit+DIG0);
|
||||
|
||||
LED_PORT = leddigitbuffer[leddigit];
|
||||
LEDDIG_PORT = _BV(leddigit);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue