Update to work on PicoCalc with Pico 2W.
This commit is contained in:
		
							parent
							
								
									75b2785b5a
								
							
						
					
					
						commit
						1c3052c977
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2002
									
								
								ulisp-arm.ino
								
								
								
								
							
							
						
						
									
										2002
									
								
								ulisp-arm.ino
								
								
								
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -0,0 +1,50 @@ | ||||||
|  | /*
 | ||||||
|  |  User Extensions | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | // Definitions
 | ||||||
|  | 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))); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // Symbol names
 | ||||||
|  | const char stringnow[] PROGMEM = "now"; | ||||||
|  | 
 | ||||||
|  | // Documentation strings
 | ||||||
|  | const char docnow[] PROGMEM = "(now [hh mm ss])\n" | ||||||
|  | "Sets the current time, or with no arguments returns the current time\n" | ||||||
|  | "as a list of three integers (hh mm ss)."; | ||||||
|  | 
 | ||||||
|  | // Symbol lookup table
 | ||||||
|  | const tbl_entry_t lookup_table2[] PROGMEM = { | ||||||
|  |   { stringnow, fn_now, 0203, docnow }, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // Table cross-reference functions
 | ||||||
|  | 
 | ||||||
|  | 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]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | unsigned int tablesize (int n) { | ||||||
|  |   return tablesizes[n]; | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue