From d132f803d9488c28a9b0ecbd58d859cca706f62c Mon Sep 17 00:00:00 2001 From: WarL0ck Date: Mon, 18 Nov 2013 21:27:01 +0700 Subject: [PATCH] Optimize --- Rmodule/Rmodule.aps | 2 +- Rmodule/default/Makefile | 2 +- Rmodule/main.c | 63 ++++++++++++++++++++++++---------------- Rmodule/res/strings.h | 19 ++++++++---- Rmodule/rmodule.aws | 2 +- 5 files changed, 54 insertions(+), 34 deletions(-) diff --git a/Rmodule/Rmodule.aps b/Rmodule/Rmodule.aps index 101764b..f98c53f 100755 --- a/Rmodule/Rmodule.aps +++ b/Rmodule/Rmodule.aps @@ -1 +1 @@ -Rmodule14-Nov-2013 11:48:5717-Nov-2013 15:50:59241014-Nov-2013 11:48:5744, 19, 0, 730AVR GCCdefault\Rmodule.elfc:\Hard\Rmodule\AVR SimulatorATmega8.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cuart\uart.conewire\onewire.cC:\Hard\Rmodule\uart\uart_addon.cuart\uart.hres\strings.honewire\onewire.hC:\Hard\Rmodule\uart\uart_addon.hdefault\Rmodule.lssdefault\Rmodule.mapdefaultNOatmega8111Rmodule.elfdefault\1-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\avr-gcc.exeC:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\make.exec:\Hard\Rmodule\uart\uart.hc:\Hard\Rmodule\res\strings.hc:\Hard\Rmodule\onewire\onewire.hc:\Hard\Rmodule\main.cc:\Hard\Rmodule\uart\uart.cc:\Hard\Rmodule\onewire\onewire.c00000main.c100001onewire\onewire.h1 +Rmodule14-Nov-2013 11:48:5718-Nov-2013 21:18:20241014-Nov-2013 11:48:5744, 19, 0, 730AVR GCCdefault\Rmodule.elfc:\Hard\Rmodule\AVR SimulatorATmega8.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cuart\uart.conewire\onewire.cC:\Hard\Git\Rmodule\uart\uart_addon.cuart\uart.hres\strings.honewire\onewire.hC:\Hard\Git\Rmodule\uart\uart_addon.hdefault\Rmodule.lssdefault\Rmodule.mapdefaultNOatmega8111Rmodule.elfdefault\1-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\avr-gcc.exeC:\Program Files\Atmel\AVR Tools\AVR Toolchain\bin\make.exec:\Hard\Rmodule\uart\uart.hc:\Hard\Rmodule\res\strings.hc:\Hard\Rmodule\onewire\onewire.hC:\Hard\Git\Rmodule\uart\uart_addon.hc:\Hard\Rmodule\main.cc:\Hard\Rmodule\uart\uart.cc:\Hard\Rmodule\onewire\onewire.cC:\Hard\Git\Rmodule\uart\uart_addon.c00000main.c100001res\strings.h1 diff --git a/Rmodule/default/Makefile b/Rmodule/default/Makefile index f3bb8d5..12f6b4f 100755 --- a/Rmodule/default/Makefile +++ b/Rmodule/default/Makefile @@ -55,7 +55,7 @@ uart.o: ../uart/uart.c onewire.o: ../onewire/onewire.c $(CC) $(INCLUDES) $(CFLAGS) -c $< -uart_addon.o: ../uart/uart_addon.c +uart_addon.o: ../../Git/Rmodule/uart/uart_addon.c $(CC) $(INCLUDES) $(CFLAGS) -c $< ##Link diff --git a/Rmodule/main.c b/Rmodule/main.c index b8114bb..21dfab6 100755 --- a/Rmodule/main.c +++ b/Rmodule/main.c @@ -5,13 +5,12 @@ #include #include "uart/uart.h" #include "uart/uart_addon.h" -#include "res/strings.h" #include "onewire/onewire.h" - +#include "res/strings.h" #define UART_BAUD_RATE 19200 -unsigned char getcmd(void){ +unsigned char get_uart_char(void){ unsigned int res; do{ res = uart_getc(); @@ -19,29 +18,41 @@ unsigned char getcmd(void){ return (unsigned char) res; } +static int get_uart_line(char *pbuf, int len_ln){ + int i = 0; + unsigned char c; + len_ln=len_ln-1; + + while((c=get_uart_char()) != 0x0D && i0){ + if (strcmp_P(cmd, CmdLD)==0){ + getListDevices(); + } + if (strcmp_P(cmd, CmdHelp)==0){ + uart_puts_p(HelpTitle); + uart_puts_p(HelpItem1); + uart_puts_p(HelpItem2); + } } } - - while(1){ } - } diff --git a/Rmodule/res/strings.h b/Rmodule/res/strings.h index 84fcbe2..cea7272 100755 --- a/Rmodule/res/strings.h +++ b/Rmodule/res/strings.h @@ -1,10 +1,17 @@ #include -// Главное меню -const char MainMenuItemTitle[] PROGMEM = "\r\n---==== Main menu ---"; -const char MainMenuItem1[] PROGMEM = "\r\n1) List devices"; -const char MainMenuItem2[] PROGMEM = "\r\n2) Selected device : "; -const char MainMenuItemQuit[] PROGMEM = "\r\nq) Quit"; -const char MainMenuItemPrompt[] PROGMEM = "\r\n# "; +#define CRLF "\r\n" +// +const char CmdLD[] PROGMEM = "ld"; +const char CmdHelp[] PROGMEM = "h"; + +// Список команд +const char HelpTitle[] PROGMEM = CRLF "Command list:"; +const char HelpItem1[] PROGMEM = CRLF "ld - List devices"; +const char HelpItem2[] PROGMEM = CRLF "h - Show this help"; +const char CmdPrompt[] PROGMEM = CRLF "$ "; + +// Разные нужные строки +const char ScanStr[] PROGMEM = CRLF "Scanning 1-wire bus" CRLF; diff --git a/Rmodule/rmodule.aws b/Rmodule/rmodule.aws index 7b7681b..f836f76 100755 --- a/Rmodule/rmodule.aws +++ b/Rmodule/rmodule.aws @@ -1 +1 @@ - +