Changeset 56
- Timestamp:
- 11/03/09 08:09:41 (3 years ago)
- Location:
- flukso/trunk/uc
- Files:
-
- 4 modified
-
main.c (modified) (5 diffs)
-
main.h (modified) (1 diff)
-
wiring/serial.c (modified) (3 diffs)
-
wiring/wiring.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
flukso/trunk/uc/main.c
r53 r56 37 37 38 38 // variable declarations 39 uint8_t i; 40 39 41 volatile struct state aux[4] = {{false, false, START}, {false, false, START}, {false, false, START}, {false, false, START}}; 40 42 … … 112 114 ADCSRA |= (1<<ADEN) | (1<<ADSC); 113 115 114 printString("msg metervalues written to EEPROM (BROWN-OUT)\n");116 printString("msg BROWN-OUT\n"); 115 117 } 116 118 … … 120 122 eeprom_write_block((const void*)&measurements[i].value, (void*)&EEPROM_measurements[i].value, 4); 121 123 122 printString("msg metervalues written to EEPROM (WDT)\n");124 printString("msg WDT\n"); 123 125 } 124 126 … … 211 213 void send(const struct sensor *measurement) 212 214 { 213 uint8_t i, length; 214 char buffer[49]; 215 216 // determine the length of value 217 ltoa(measurement->value, buffer, 10); 218 length = strlen(buffer); 219 220 strcpy(buffer, "pls "); 221 strcpy(&buffer[4], measurement->id); 222 strcpy(&buffer[36], ":"); 223 // insert leading 0's 224 for (i=0; i<10-length; i++) strcpy(&buffer[37+i], "0"); 225 ltoa(measurement->value, &buffer[47-length], 10); 226 strcpy(&buffer[47], "\n"); 227 228 printString(buffer); 215 uint8_t i = 46; 216 uint32_t value = measurement->value; 217 char pulse[49]; 218 219 // generate pulse message structure 220 strcpy(pulse, "pls "); 221 strcpy(&pulse[4], measurement->id); 222 strcpy(&pulse[36], ":0000000000\n"); 223 224 do { // generate digits in reverse order 225 pulse[i--] = '0' + value % 10; // get next digit 226 } while ((value /= 10) > 0); // delete it 227 228 printString(pulse); 229 229 230 230 // blink the green LED … … 258 258 for (i=0; i<4; i++) _delay_ms(5000); 259 259 260 serialFlush(); 260 261 WDT_on(); 261 262 -
flukso/trunk/uc/main.h
r55 r56 51 51 52 52 // datastructures 53 uint8_t i;54 55 53 struct state { 56 54 boolean pulse; -
flukso/trunk/uc/wiring/serial.c
r1 r56 29 29 // location to which to write the next incoming character and rx_buffer_tail 30 30 // is the index of the location from which to read. 31 #define RX_BUFFER_SIZE 12831 #define RX_BUFFER_SIZE 64 32 32 33 33 unsigned char rx_buffer[RX_BUFFER_SIZE]; … … 129 129 } 130 130 131 void printMode(int mode)132 {133 // do nothing, we only support serial printing, not lcd.134 }135 136 131 void printByte(unsigned char c) 137 132 { 138 133 serialWrite(c); 139 }140 141 void printNewline()142 {143 printByte('\n');144 134 } 145 135 … … 195 185 printIntegerInBase(n, 2); 196 186 } 197 198 /* Including print() adds approximately 1500 bytes to the binary size,199 * so we replace it with the smaller and less-confusing printString(),200 * printInteger(), etc.201 void print(const char *format, ...)202 {203 char buf[256];204 va_list ap;205 206 va_start(ap, format);207 vsnprintf(buf, 256, format, ap);208 va_end(ap);209 210 printString(buf);211 }212 */ -
flukso/trunk/uc/wiring/wiring.h
r1 r56 100 100 int serialRead(void); 101 101 void serialFlush(void); 102 void printMode(int);103 102 void printByte(unsigned char c); 104 void printNewline(void);105 103 void printString(const char *s); 106 104 void printInteger(long n);
