bugfixes, live check on avr

working for now
This commit is contained in:
Lucas Pleß 2013-06-13 00:13:53 +02:00
parent 147a6d8e25
commit 0b1a157bfd
7 changed files with 108 additions and 114 deletions

View File

@ -2,13 +2,10 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9fad4545-a424-4a82-86dc-76602cf3eef3" name="Default" comment=""> <list default="true" id="9fad4545-a424-4a82-86dc-76602cf3eef3" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/powerboard/src/asciiart.h" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/Makefile" afterPath="$PROJECT_DIR$/powerboard/Makefile" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/Makefile" afterPath="$PROJECT_DIR$/powerboard/Makefile" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/main.c" afterPath="$PROJECT_DIR$/powerboard/src/main.c" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/main.c" afterPath="$PROJECT_DIR$/powerboard/src/main.c" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/main.h" afterPath="$PROJECT_DIR$/powerboard/src/main.h" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/main.h" afterPath="$PROJECT_DIR$/powerboard/src/main.h" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/uart.h" afterPath="$PROJECT_DIR$/powerboard/src/uart.h" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/powerboard.iml" afterPath="$PROJECT_DIR$/powerboard/powerboard.iml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/uart.c" afterPath="$PROJECT_DIR$/powerboard/src/uart.c" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/utils.c" afterPath="$PROJECT_DIR$/powerboard/src/utils.c" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/utils.c" afterPath="$PROJECT_DIR$/powerboard/src/utils.c" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/utils.h" afterPath="$PROJECT_DIR$/powerboard/src/utils.h" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/powerboard/src/utils.h" afterPath="$PROJECT_DIR$/powerboard/src/utils.h" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
@ -16,8 +13,8 @@
<ignored path="bikegenerator.iws" /> <ignored path="bikegenerator.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
<file path="/Makefile" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032328243" ignored="false" /> <file path="/Makefile" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032328243" ignored="false" />
<file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371043806331" ignored="false" /> <file path="/Dummy.txt" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371043904548" ignored="false" />
<file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371032185953" ignored="false" /> <file path="/main.c" changelist="9fad4545-a424-4a82-86dc-76602cf3eef3" time="1371074113650" ignored="false" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -78,46 +75,10 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf>
<file leaf-file-name="Makefile" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/powerboard/Makefile">
<provider selected="true" editor-type-id="text-editor">
<state line="63" column="34" selection-start="1644" selection-end="1644" vertical-scroll-proportion="-17.678572">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.c" pinned="false" current="true" current-in-tab="true"> <file leaf-file-name="main.c" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/powerboard/src/main.c"> <entry file="file://$PROJECT_DIR$/powerboard/src/main.c">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="169" column="0" selection-start="4305" selection-end="4305" vertical-scroll-proportion="0.66820276"> <state line="179" column="32" selection-start="4434" selection-end="4434" vertical-scroll-proportion="0.67713004">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.h" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/powerboard/src/main.h">
<provider selected="true" editor-type-id="text-editor">
<state line="24" column="34" selection-start="646" selection-end="646" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="utils.c" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.c">
<provider selected="true" editor-type-id="text-editor">
<state line="30" column="0" selection-start="649" selection-end="649" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="utils.h" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.h">
<provider selected="true" editor-type-id="text-editor">
<state line="6" column="33" selection-start="185" selection-end="185" vertical-scroll-proportion="0.0">
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -142,22 +103,23 @@
<option name="changedFiles"> <option name="changedFiles">
<list> <list>
<option value="$PROJECT_DIR$/powerboard/src/uart.c" /> <option value="$PROJECT_DIR$/powerboard/src/uart.c" />
<option value="$PROJECT_DIR$/powerboard/src/uart.h" />
<option value="$PROJECT_DIR$/powerboard/src/asciiart.h" /> <option value="$PROJECT_DIR$/powerboard/src/asciiart.h" />
<option value="$PROJECT_DIR$/powerboard/src/adc.h" /> <option value="$PROJECT_DIR$/powerboard/src/adc.h" />
<option value="$PROJECT_DIR$/powerboard/src/adc.c" /> <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.c" />
<option value="$PROJECT_DIR$/powerboard/src/utils.h" /> <option value="$PROJECT_DIR$/powerboard/src/utils.h" />
<option value="$PROJECT_DIR$/powerboard/src/main.h" />
<option value="$PROJECT_DIR$/powerboard/Makefile" /> <option value="$PROJECT_DIR$/powerboard/Makefile" />
<option value="$PROJECT_DIR$/powerboard/src/main.c" /> <option value="$PROJECT_DIR$/powerboard/src/main.c" />
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds">
<option name="x" value="1596" /> <option name="x" value="-4" />
<option name="width" value="1928" /> <option name="y" value="25" />
<option name="height" value="1058" /> <option name="width" value="1608" />
<option name="height" value="853" />
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true"> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<OptionsSetting value="true" id="Add" /> <OptionsSetting value="true" id="Add" />
@ -391,14 +353,18 @@
<created>1371043815539</created> <created>1371043815539</created>
<updated>1371043815539</updated> <updated>1371043815539</updated>
</task> </task>
<option name="localTasksCounter" value="4" /> <task id="LOCAL-00004" summary="working, refactured a bit, optimised for size">
<created>1371043908804</created>
<updated>1371043908804</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="1596" y="0" width="1928" height="1058" extended-state="6" /> <frame x="-4" y="25" width="1608" height="853" extended-state="6" />
<editor active="false" /> <editor active="false" />
<layout> <layout>
<window_info id="Changes" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25412542" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" /> <window_info id="Changes" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.328125" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@ -413,7 +379,7 @@
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" /> <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2497332" sideWeight="0.7458746" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3011583" sideWeight="0.671875" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@ -464,7 +430,7 @@
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="false" /> <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="false" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" /> <option name="FORCE_NON_EMPTY_COMMENT" value="false" />
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" /> <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
<option name="LAST_COMMIT_MESSAGE" value="optimisations in adc code" /> <option name="LAST_COMMIT_MESSAGE" value="working, refactured a bit, optimised for size" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" /> <option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" /> <option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@ -481,6 +447,7 @@
<MESSAGE value="- added 3rd party uart lib&#10;- added measurements for voltage and current" /> <MESSAGE value="- added 3rd party uart lib&#10;- added measurements for voltage and current" />
<MESSAGE value="added first draft of overvoltage protection by using dump load" /> <MESSAGE value="added first draft of overvoltage protection by using dump load" />
<MESSAGE value="optimisations in adc code" /> <MESSAGE value="optimisations in adc code" />
<MESSAGE value="working, refactured a bit, optimised for size" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager />
@ -518,22 +485,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/uart.c">
<provider selected="true" editor-type-id="text-editor">
<state line="81" column="32" selection-start="2066" selection-end="3000" vertical-scroll-proportion="0.0">
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/uart.h">
<provider selected="true" editor-type-id="text-editor">
<state line="9" column="35" selection-start="301" selection-end="480" vertical-scroll-proportion="0.20737328">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/adc.c"> <entry file="file://$PROJECT_DIR$/powerboard/src/adc.c">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="8" column="39" selection-start="169" selection-end="169" vertical-scroll-proportion="0.1843318"> <state line="8" column="39" selection-start="169" selection-end="169" vertical-scroll-proportion="0.1843318">
@ -548,37 +499,53 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.h"> <entry file="file://$PROJECT_DIR$/powerboard/src/uart.c">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="6" column="33" selection-start="185" selection-end="185" vertical-scroll-proportion="0.0"> <state line="80" column="76" selection-start="2948" selection-end="2948" vertical-scroll-proportion="-1.9201807">
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/main.h">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="36" selection-start="864" selection-end="864" vertical-scroll-proportion="0.0">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/Makefile"> <entry file="file://$PROJECT_DIR$/powerboard/src/utils.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="63" column="34" selection-start="1644" selection-end="1644" vertical-scroll-proportion="-17.678572"> <state line="5" column="32" selection-start="142" selection-end="142" vertical-scroll-proportion="0.0">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/utils.c"> <entry file="file://$PROJECT_DIR$/powerboard/src/utils.c">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="30" column="0" selection-start="649" selection-end="649" vertical-scroll-proportion="0.0"> <state line="21" column="21" selection-start="442" selection-end="442" vertical-scroll-proportion="0.46528804">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/main.h"> <entry file="file://$PROJECT_DIR$/powerboard/src/uart.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="24" column="34" selection-start="646" selection-end="646" vertical-scroll-proportion="0.0"> <state line="176" column="0" selection-start="6326" selection-end="6326" vertical-scroll-proportion="0.7784343">
<folding />
</state>
</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">
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/powerboard/src/main.c"> <entry file="file://$PROJECT_DIR$/powerboard/src/main.c">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state line="169" column="0" selection-start="4305" selection-end="4305" vertical-scroll-proportion="0.66820276"> <state line="179" column="32" selection-start="4434" selection-end="4434" vertical-scroll-proportion="0.67713004">
<folding /> <folding />
</state> </state>
</provider> </provider>

View File

@ -60,7 +60,7 @@ CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -Wa,-adhlns=$(<:.c=.lst) CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += $(CSTANDARD) CFLAGS += $(CSTANDARD)
CFLAGS += -DF_CPU=$(F_CPU) -DDEBUG CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG

View File

@ -46,28 +46,28 @@ void measure(void) {
} }
uint8_t get_power(uint16_t voltage, int16_t currents) { uint8_t get_power(uint16_t voltage, int16_t currents) {
return (voltage * (currents/100)) / 100; return (voltage/100 * (currents/100)) / 100 ;
} }
void pretty_print_all_values() { void pretty_print_all_values(void) {
uart_puts_P("Voltage: "); uart_puts_P("Voltage: ");
uart_print_voltage(voltage); uart_print_uint16(voltage);
uart_puts_P("V\r\n"); uart_puts_P("mV\r\n");
uart_puts_P("Load: "); uart_puts_P("Load: ");
uart_print_current(current_out); uart_print_int16(current_out);
uart_puts_P("mA "); uart_puts_P("mA ");
uart_print_uint16( get_power(voltage, current_out)); uart_print_uint16( get_power(voltage, current_out));
uart_puts_P("W\r\n"); uart_puts_P("W\r\n");
uart_puts_P("Generator: "); uart_puts_P("Generator: ");
uart_print_current(current_in); uart_print_int16(current_in);
uart_puts_P("mA "); uart_puts_P("mA ");
uart_print_uint16(get_power(voltage, current_in)); uart_print_uint16(get_power(voltage, current_in));
uart_puts_P("W\r\n"); uart_puts_P("W\r\n");
} }
void handle_over_and_undervoltage() { void handle_over_and_undervoltage(void) {
if(voltage > OVERVOLTAGE1) { if(voltage > OVERVOLTAGE1) {
overvoltage_off_counter1 = 0; overvoltage_off_counter1 = 0;
if(overvoltage_counter1<OVERVOLTAGE_TIMEOUT1) overvoltage_counter1++; if(overvoltage_counter1<OVERVOLTAGE_TIMEOUT1) overvoltage_counter1++;
@ -157,8 +157,9 @@ int main(void) {
adc_init(); adc_init();
timer_init(); timer_init();
uart_init(UART_BAUD_SELECT(9600,F_CPU)); uart_init(UART_BAUD_SELECT(38400,F_CPU));
uint16_t uart_char;
while(1) { while(1) {
@ -166,9 +167,50 @@ int main(void) {
measure(); measure();
pretty_print_all_values(); //pretty_print_all_values();
handle_over_and_undervoltage(); handle_over_and_undervoltage();
}
uart_char = uart_getc();
if(uart_char != UART_NO_DATA) {
switch(uart_char & 0xff) {
case 'p':
pretty_print_all_values();
break;
case 'v':
uart_print_voltage(voltage);
break;
case 'i':
uart_print_uint16(current_in);
break;
case 'o':
uart_print_uint16(current_out);
case 'g':
uart_print_uint16(get_power(voltage, current_in));
break;
case 'c':
uart_print_uint16(get_power(voltage, current_in));
break;
case 'a':
uart_print_voltage(voltage);
uart_putc(':');
uart_print_uint16(current_in);
uart_putc(':');
uart_print_uint16(current_out);
uart_putc(':');
uart_print_uint16(get_power(voltage, current_in));
uart_putc(':');
uart_print_uint16(get_power(voltage, current_out));
break;
}
uart_putc('\n');
} }
} }

View File

@ -20,16 +20,16 @@
#define IS_LOAD_ON PIND &= _BV(LOADSW); #define IS_LOAD_ON PIND &= _BV(LOADSW);
#define UNDERVOLTAGE 112 #define UNDERVOLTAGE 11200
#define OVERVOLTAGE1 141 #define OVERVOLTAGE1 14100
#define OVERVOLTAGE2 150 #define OVERVOLTAGE2 15000
#define OVERVOLTAGE_TIMEOUT1 20 #define OVERVOLTAGE_TIMEOUT1 5
#define OVERVOLTAGE_TIMEOUT2 20 #define OVERVOLTAGE_TIMEOUT2 3
#define UNDERVOLTAGE_TIMEOUT 20 #define UNDERVOLTAGE_TIMEOUT 5
#define CURRENT_OFFSET 511 #define CURRENT_OFFSET 511
#define CURRENT_PER_TICK 72 #define CURRENT_PER_TICK 72
#define VOLTAGE_PER_TICK 15 #define VOLTAGE_PER_TICK 15.5
#endif #endif

View File

@ -175,21 +175,6 @@ extern void uart_puts_p(const char *s );
/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */
extern void uart1_init(unsigned int baudrate);
/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */
extern unsigned int uart1_getc(void);
/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */
extern void uart1_putc(unsigned char data);
/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */
extern void uart1_puts(const char *s );
/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */
extern void uart1_puts_p(const char *s );
/** @brief Macro to automatically put a string constant into program memory */
#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s))
/**@}*/
#endif // UART_H #endif // UART_H

View File

@ -13,13 +13,13 @@ void wait(uint8_t count) {
void uart_print_voltage(uint16_t x) { void uart_print_voltage(uint16_t x) {
uart_putc(48 + (x / 10000)); uart_putc(48 + (x / 10000));
uart_putc(48 + (x % 10000 /1000)); uart_putc(48 + (x % 10000 /1000));
uart_putc(48 + (x % 1000 / 100 ));
uart_putc(48 + (x % 100 / 10 ));
uart_putc('.'); uart_putc('.');
uart_putc(48 + (x % 10)); uart_putc(48 + (x % 1000 / 100 ));
//uart_putc(48 + (x % 100 / 10 ));
//uart_putc(48 + (x % 10));
} }
void uart_print_current(int16_t x) { void uart_print_int16(int16_t x) {
if(x <0) uart_putc('-'); if(x <0) uart_putc('-');
uart_putc(48 + (x / 10000)); uart_putc(48 + (x / 10000));
uart_putc(48 + (x % 10000 /1000)); uart_putc(48 + (x % 10000 /1000));

View File

@ -3,7 +3,7 @@
extern void wait(uint8_t count); extern void wait(uint8_t count);
extern void uart_print_voltage(uint16_t); extern void uart_print_voltage(uint16_t);
extern void uart_print_current(int16_t); extern void uart_print_int16(int16_t);
extern void uart_print_uint16(uint16_t); extern void uart_print_uint16(uint16_t);
#endif #endif