comparison sprink.c @ 7:78983502a4e9

Use base 16 for IO port values
author Daniel O'Connor <darius@dons.net.au>
date Sun, 15 Feb 2015 17:47:25 +1030
parents 951277329ee6
children
comparison
equal deleted inserted replaced
6:7b9a1affcc94 7:78983502a4e9
1 /* 1 /*
2 * Sprinkler relay control 2 * Sprinkler relay control
3 * 3 *
4 * Copyright (c) 2009 4 * Copyright (c) 2015
5 * Daniel O'Connor <darius@dons.net.au>. All rights reserved. 5 * Daniel O'Connor <darius@dons.net.au>. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
257 if (argc != 3) { 257 if (argc != 3) {
258 printf_P(PSTR("Bad usage\r\n")); 258 printf_P(PSTR("Bad usage\r\n"));
259 return; 259 return;
260 } 260 }
261 261
262 val = strtol(argv[2], &eptr, 0); 262 val = strtol(argv[2], &eptr, 16);
263 if (eptr == argv[2]) { 263 if (eptr == argv[2]) {
264 printf_P(PSTR("Unable to parse val\r\n")); 264 printf_P(PSTR("Unable to parse val\r\n"));
265 return; 265 return;
266 } 266 }
267 267
318 printf_P(PSTR("Unknown port\r\n")); 318 printf_P(PSTR("Unknown port\r\n"));
319 return; 319 return;
320 } 320 }
321 printf_P(PSTR("DDR%c => 0x%02x\r\n"), toupper(argv[1][0]), val); 321 printf_P(PSTR("DDR%c => 0x%02x\r\n"), toupper(argv[1][0]), val);
322 } else { 322 } else {
323 val = strtol(argv[2], &eptr, 0); 323 val = strtol(argv[2], &eptr, 16);
324 if (eptr == argv[2]) { 324 if (eptr == argv[2]) {
325 printf_P(PSTR("Unable to parse val\r\n")); 325 printf_P(PSTR("Unable to parse val\r\n"));
326 return; 326 return;
327 } 327 }
328 328