Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.52 KB | None | 0 0
  1. package;
  2.  
  3. import test.TestClass1;
  4. import test.TestClass2;
  5.  
  6. class Main {
  7.     // class level class decl
  8.     private var _t1:TestClass1 = new TestClass1();
  9.    
  10.     function setup() {
  11.         Arduino.pinMode(Arduino.LED_BUILTIN, Arduino.OUTPUT);
  12.     }
  13.    
  14.     function loop() {
  15.         // different iterators
  16.         var numberArray = [1, 2, 3, 4, 5];
  17.         trace(numberArray[1]);
  18.        
  19.         for (n in numberArray) {
  20.             trace(n);
  21.         }
  22.        
  23.         var stringArray = ["a", "b", "c"];
  24.         trace(stringArray[1]);
  25.         for (s in stringArray) {
  26.             trace(s);
  27.         }
  28.        
  29.         var objectArray = [ new TestClass1(),  new TestClass1(),  new TestClass1() ];
  30.         trace(objectArray[1].get());
  31.        
  32.         for (o in objectArray) {
  33.             o.set(111);
  34.             trace(o.get());
  35.         }
  36.        
  37.         // function level class decl
  38.         var t2 = new TestClass2();
  39.         // set value in t1 via t2 (ensure pass as ref)
  40.         t2.setViaRef(_t1, 500);
  41.        
  42.         Arduino.digitalWrite(Arduino.LED_BUILTIN, Arduino.HIGH);
  43.        
  44.         trace("Delaying for " + _t1.get() + "ms");
  45.         Arduino.delay(_t1.get());
  46.        
  47.         Arduino.digitalWrite(Arduino.LED_BUILTIN, Arduino.LOW);
  48.        
  49.         trace("Delaying for " + _t1.getInline() + "ms");
  50.         Arduino.delay(_t1.getInline());
  51.        
  52.         var mem = MemoryFree.freeMemory();
  53.         trace("Memory free: " + mem + "bytes");        
  54.     }
  55.    
  56.     static function main() {
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement