Quality of life improvements:
- Add standard library - Update display
This commit is contained in:
@@ -3,24 +3,30 @@
|
||||
*/
|
||||
|
||||
// Definitions
|
||||
object *fn_now (object *args, object *env) {
|
||||
(void) env;
|
||||
static unsigned long Offset;
|
||||
unsigned long now = millis()/1000;
|
||||
int nargs = listlength(args);
|
||||
object *
|
||||
fn_now(object *args, object *env)
|
||||
{
|
||||
(void) env;
|
||||
static unsigned long Offset;
|
||||
unsigned long now = millis()/1000;
|
||||
int nargs = listlength(args);
|
||||
|
||||
// Set time
|
||||
if (nargs == 3) {
|
||||
Offset = (unsigned long)((checkinteger(first(args))*60 + checkinteger(second(args)))*60
|
||||
+ checkinteger(third(args)) - now);
|
||||
} else if (nargs > 0) error2(PSTR("wrong number of arguments"));
|
||||
|
||||
// Return time
|
||||
unsigned long secs = Offset + now;
|
||||
object *seconds = number(secs%60);
|
||||
object *minutes = number((secs/60)%60);
|
||||
object *hours = number((secs/3600)%24);
|
||||
return cons(hours, cons(minutes, cons(seconds, NULL)));
|
||||
// Set time
|
||||
if (nargs == 3) {
|
||||
Offset = (unsigned long)((checkinteger(first(args))*60 \
|
||||
+ checkinteger(second(args)))*60 \
|
||||
+ checkinteger(third(args)) - now);
|
||||
} else if (nargs > 0) {
|
||||
error2(PSTR("wrong number of arguments"));
|
||||
}
|
||||
|
||||
// Return time
|
||||
unsigned long secs = Offset + now;
|
||||
object *seconds = number(secs%60);
|
||||
object *minutes = number((secs/60)%60);
|
||||
object *hours = number((secs/3600)%24);
|
||||
|
||||
return cons(hours, cons(minutes, cons(seconds, NULL)));
|
||||
}
|
||||
|
||||
// Symbol names
|
||||
@@ -41,10 +47,14 @@ const tbl_entry_t lookup_table2[] PROGMEM = {
|
||||
tbl_entry_t *tables[] = {lookup_table, lookup_table2};
|
||||
const unsigned int tablesizes[] = { arraysize(lookup_table), arraysize(lookup_table2) };
|
||||
|
||||
const tbl_entry_t *table (int n) {
|
||||
return tables[n];
|
||||
const tbl_entry_t *
|
||||
table(int n)
|
||||
{
|
||||
return tables[n];
|
||||
}
|
||||
|
||||
unsigned int tablesize (int n) {
|
||||
return tablesizes[n];
|
||||
unsigned int
|
||||
tablesize(int n)
|
||||
{
|
||||
return tablesizes[n];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user