void main()                                  // Main function
{
  badge_setup();                             // Call badge setup

  oledprint("BUTTONS");                      // Large display heading
  text_size(SMALL);                          // Switch to small text
  cursor(0, 4);                              // Small cursor row 4
  oledprint("PAD:   6543210");               // Display bit index
  cursor(0, 5);                              // Next line
  oledprint("STATE:");                       // Display state 
  cursor(0, 7);                              // Next line
  oledprint("EXIT: Press OSH");              // User prompt to exit
  
  while(1)                                   // States loop
  {
    states = buttons();                      // Load buttons output to states
    leds(states);                            // Light up corresponding LEDs
    
    cursor(7, 5);                            // Position cursor
    oledprint("%07b", states);               // Display states as binary number
    if(states == 0b1000000) break;           // If OSH pressed, exit loop
  }
  
  pause(400);                                 // Wait for 4/10 s

  text_size(LARGE);                           // Large text
  clear();                                    // Clear display
  oledprint("ALL DONE");                      // Done message
}
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  while(1)                                   // Main loop
  {
    cursor(0, 0);                            // Cursor to 0
    oledprint("  ON ");                      // Display ON message
    for(int n = 0; n < 6; n++)               // Count 0 to 5
    {
      led(n, ON);                            // 0 to 5 lights on
      cursor(0, 1);                          // Cursor 2nd line
      oledprint(" n = %d", n);               // Display n value
      pause(400);                            // Wait 4/10 s
    }
    cursor(0, 0);                            // Cursor to top-left
    oledprint("  OFF");                      // Display OFF message
    for(int n = 0; n < 6; n++)               // Count 0 to 5 again
    {
      led(n, OFF);                           // Turn off each LED
      cursor(0, 1);                          // Position cursor 2nd line
      oledprint(" n = %d", n);               // Display n
      pause(400);                            // Wait 4/10 s
    }
  }
}      
int main()                                    // Main function
{
  badge_setup();                              // Set up badge systems

  audio = sound_run(9, 10);                   // Run sound, get audio pointer
  
  oledprint("CH  = 0 NOTE=C5 ");              // Display Ch and note
  sound_note(audio, 0, C5);                   // Play ch and note
  pause(250);
  oledprint("CH  = 0 NOTE=D5 ");              // Repeat for octave
  sound_note(audio, 0, D5);
  pause(250);
  oledprint("CH  = 0 NOTE=E5 ");
  sound_note(audio, 0, E5);
  pause(250);
  oledprint("CH  = 0 NOTE=F5 ");
  sound_note(audio, 0, F5);
  pause(250);
  oledprint("CH  = 0 NOTE=G5 ");
  sound_note(audio, 0, G5);
  pause(250);
  oledprint("CH  = 0 NOTE=A5 ");
  sound_note(audio, 0, A5);
  pause(250);
  oledprint("CH  = 0 NOTE=B5 ");
  sound_note(audio, 0, B5);
  pause(250);
  oledprint("CH  = 0 NOTE=C6 ");              // Up an octave   
  sound_note(audio, 0, C6);
  pause(500);
  oledprint("CH  = 0  f  = 0 ");              // Sound off
  sound_freq(audio, 0, 0);
}
Esempio n. 4
0
void main()                   // Main function (standard C entry point)
{
  badge_setup();              // Call badge setup

  Init();                     // Initialize the game board
  GameLoop();                 // Run the game loop
}
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  while(1)                                   // Main loop
  {
    oledprint("  True  ");                   // True (black background)
    pause(2000);                             // Wait 2 s
    clear();                                 // Clear the screen
    invert(1);                               // Set invert
    oledprint("Inverted");                   // Display w/ white background
    pause(2000);                             // Wait 2 s
    clear();                                 // Clear again
    invert(0);                               // Back to true
  }
}
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  oledprint(" X Tilt");
  while(1)
  {
    x = accel(AX);                           // Raw measurement
    // Convert from centi-gravity -> degrees.
	degrees = tilt_angle(x);                 // Function call 
    
    cursor(0, 1);                            // Displayed
    oledprint(" %02d deg ", degrees);

    pause(20);                               // 1/50 s delay before repeat
  }    
}
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  while(1)                                   // Main loop
  {
    x = accel(AX);                           // Get accelerometer values 
    y = accel(AY);
    
    cursor(0, 0);                            // Display
    oledprint("x = %03d ", x);
    cursor(0, 1);
    oledprint("y = %03d ", y);

    pause(20);                               // Wait 1/50 s before repeat
  }    
}
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  text_size(SMALL);    
  oledprint("Use SimpleIDE\nTerminal.");
  
  if(!stored(wilma))                         // Check first, if repeat skip
    store(wilma);
  if(!stored(betty)) 
    store(betty);
  if(!stored(fred))                          // ...but if not repeat, store
    store(fred);
  if(!stored(barney)) 
    store(barney);
    
  contacts_displayAll();                       // Display contacts
}  
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  oledprint("Rotation");                     
  while(1)
  {
    x = accel(AX);                           // Get x and y axes
    y = accel(AY);
    // Convert from xy centi-gravity 
	// to degrees of rotation.
    degrees = xy_rotation(x, y);             // Function call
    
    cursor(0, 1);                            // Display result
    oledprint("%03d deg ", degrees);

    pause(20);
  }    
}
void main()                                    // Main function
{
  badge_setup();                               // Start badge systems
  dt_run(dt);                                  // Start system timer with dt

  oledprint("Day/Time");                       // Display heading
  text_size(SMALL);                            // Change to small text
  
  while(1)                                     // Main loop
  {
    dt = dt_get();                             // Get system time
    int hrs = dt.h % 12;                       // Adjust to 12 hours
    if(dt.h == 0 || dt.h == 12) hrs = 12; 
    cursor(0, 5);                              // Position cursor row 5
    // Display time with formatting flags
    oledprint("   %04d.%02d.%02d\n\n  %02d:%02d:%02d  ",
    dt.y, dt.mo, dt.d, hrs, dt.m, dt.s);
    if(dt.h >= 12) oledprint("PM");            // Display AM/PM
    else oledprint("AM");
  }      
}  
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  
  oledprint("IR Send");
  text_size(SMALL);
  cursor(0, 4);
  oledprint("P17 = Education\n");
  oledprint("P16 = Sales\n");
  oledprint("P15 = Support\n");
  
  while(1)
  {
    int states = buttons();
    if(states & 0b0111000)
    {
      rgbs(RED, RED);
    }      
    switch(states)
    {
      case 0b0100000:
        irprint("%16s\n%32s\n", education.name, education.email);
        break;
      case 0b0010000:
        irprint("%16s\n%32s\n", sales.name, sales.email);
        break;
      case 0b0001000:
        irprint("%16s\n%32s\n", support.name, support.email);
        break;
    }        
    if(states)
    {
      rgbs(OFF, OFF);
      pause(600);
    }      
  }      
}  
void main()                                  // Main function
{
  badge_setup();                             // Call badge setup
  while(1)                                   // Main loop
  {
    clear();
    text_size(LARGE);
    oledprint(" IR Rcv ");
    while(1)
    {
      irlen = receive(irbuf);                // Check incoming IR
      if(irlen > 0)                          // Yes? exit while loop
      {
        break;
      }          
    }
    clear();                                 // Display incoming message 
    text_size(SMALL);
    oledprint(irbuf);
    cursor(0, 6);                            // Press button to repeat
    oledprint("Again? Any btn.");
    while(!buttons());
  }
}  
Esempio n. 13
0
void main()
{
  badge_setup();
  simpleterm_close();
  ir_start();
  ee_wipe();
  
  // Connection to host routine (FORCE CONNECTION TO HOST)
  port = fdserial_open(31, 30, 0, 115200);
  char_size(SMALL);
  cursor(2, 4);
  display("Connecting...");
  while(1)
  {
    dprint(port, "Propeller\n");
    pause(1000);  // We need this pause, since the host needs time to respond. 5 x 1 second = 10 second timeout
    if (fdserial_rxCount(port) == 0)
    {
      continue;
    }      
    else if (fdserial_rxCount(port) < 5)
    {
      fdserial_rxFlush(port);
      continue;
    }
    else dscan(port, "%s", handshake);
    // Attempt handshake and listen to response
    if (strcmp(handshake, "H0st") == 0)
    {
      break;
    }      
  }
  clear();
  
  while(1)
  {
    rgb(L, OFF);
    rgb(R, OFF);
        
    char_size(BIG);
    cursor(0, 0);
    display("HOTSPOT!");
    char_size(SMALL);
    cursor(4, 5);
    display("Start an");
    cursor(1, 6);
    display("interaction to");
    cursor(0, 7);
    display("upload your data");
    
    memset(&their, 0, sizeof(info));
    
    int t = CNT;
    int dt = CLKFREQ * 2;
    
    if (check_inbox() == 1)
    {
      clear();
      message_get(&their);
      ir_send(&my);
      
      char_size(SMALL);
      cursor(2, 2);
      display("Receiving...");
      
      while(1)
      {
        if (CNT - t > dt)
        {
          clear();
          char_size(SMALL);
          cursor(5, 2);
          display("ERROR!");
          cursor(0, 5);
          display("Please try again");
          dprint(port, "txBegin\n");  
          dprint(port, "Timeout\n");
          ee_wipe();
          clear_inbox();
          pause(2000);
          clear();
          break;
        }
        if (check_inbox() == 1)
        {
          t = CNT;
          message_get(&their);
          if(!strcmp(their.name, "txDone"))
          {
            char_size(SMALL);
            cursor(0, 5);
            display("Upload complete");
            dprint(port, "txBegin\n");
            ee_uploadContacts(port);
            ee_wipe();
            clear_inbox();
            pause(1000);
            clear();
            break;
          }
          ee_save(&their);
          dprint(port, "Name: %s\n", their.name);
          dprint(port, "Email: %s\n", their.email);       
        }
      }        
    }      
  }    
}  
void main()                                   // Main function
{
  badge_setup();                              // Call badge setup
  oledprint("Any BTN\nfor Menu");
  pause(1200);
  while(1)
  {
    clear();                                  // Display screen name
    text_size(LARGE);
    oledprint("%s", screenName);

    while(!buttons());                        // Wait for button press

    text_size(SMALL);                         // Menu
    clear();         
    oledprint("      MENU      ");
    oledprint("P17-Send        ");
    oledprint("     Receive-P27\n");
    oledprint("P15-Upload      ");
    oledprint("        Back-P25\n");
    oledprint("  Erase-OSH-All ");
    pause(250);
    
    while((states = buttons()) == 0);         // Wait for button press

    clear();                                  // Get ready to display operation
    text_size(LARGE);
    
    switch(states)                            // Handle button press
    {
      case 0b0100000:                         // P17 pressed, send IR
        clear;
        oledprint("Sending");
        rgbs(RED, RED);
        send(my); 
        rgbs(OFF, OFF);
        pause(50);
        continue;                             // Back to while(1)
      case 0b0000001:                         // P27 pressed
        break;                                // Skip to IR receive code
      case 0b0001000:
        clear();
        oledprint("Upload  ...");
        contacts_displayAll();
        oledprint("Done");
        pause(250);
        continue;                             // Back to while(1)
      case 0b1000000:                         // OSH pressed, erase EEPROM
        clear();
        oledprint("CONFIRM");
        pause(500);
        text_size(SMALL);
        cursor(0, 4);
        oledprint("Yes-OSH\n\n");
        oledprint("No-Any other btn");
        while(!(states = buttons()));         // Get confirmation
        if(states == 0b1000000)               // Yes, erase
        {
          text_size(LARGE);
          clear();
          oledprint("Wait 20s...");
          contacts_eraseAll();
          oledprint("Done!");
          pause(250);
        }          
        else                                   // No, don't erase
        {
          clear();
          pause(250);
        }   
        continue;                               // Back to while(1)  
      default:
        continue;                               // Back to while(1)
    }

    // P27 has to have been pressed to get to here
    clear();
    oledprint("IR Rcv");                      // Display ready for IR
    cursor(0, 7);
    text_size(SMALL);
    oledprint("        Back-P25");

    // Wait for IR message
    pause(250);
    irclear();                                // Clear the IR buffers
    while(1)
    {
      irlenb = receive(irbuf);
      if(irlenb > 0) break;
      states = buttons();
      if(states == 0b0000100)
      {
        led(0, OFF);
        break;
      }        
      led(0, ON);
      pause(150);
      led(0, OFF);
      pause(150);
    }
    if(states == 0b0000100) continue;
    clear();                                  // Menu, what to do with data
    oledprint(irbuf);
    cursor(0, 5);
    oledprint("       Store-P26");
    cursor(0, 6);
    oledprint("     Discard-P25");
    while((states = buttons()) == 0);         // Wait for button press
    text_size(LARGE);
    clear();
    if(states == 0b0000010)                   // If P26, store to EEPROM
    {
      if(!stored(irbuf)) store(irbuf);
      oledprint("Stored");
    }      
    if(states == 0b0000100)                   // if(P25), discard
    {
      oledprint("Discard");
    }  
    pause(500);    
  }
}  
void main()
{
  badge_setup();
  simpleterm_close();
  contacts_clearAll();
  preserve_header();
  CLKLIMIT = CLKFREQ * 2;
  
  // Connection to host routine (FORCE CONNECTION TO HOST)
  port = fdserial_open(31, 30, 0, 115200);
  text_size(SMALL);
  cursor(2, 4);
  oledprint("Connecting...");
  spkr = talk_run(9, 10);                    // Start talk process
  while(1)
  {
    dprint(port, "Propeller\n");
    pause(1000);  // We need this pause, since the host needs time to respond. 5 x 1 second = 10 second timeout
    if (fdserial_rxCount(port) == 0)
    {
      continue;
    }      
    else if (fdserial_rxCount(port) < 5)
    {
      fdserial_rxFlush(port);
      continue;
    }
    else dscan(port, "%s", handshake);
    // Attempt handshake and listen to response
    if (strcmp(handshake, "H0st") == 0)
    {
      break;
    }      
  }

  clear();
  
  talk_say(spkr, "heloa");
  while(1)
  {
    rgb(L, OFF);
    rgb(R, OFF);
    
    text_size(LARGE);
    cursor(0, 0);
    oledprint("HOTSPOT!");
    text_size(SMALL);
    cursor(4, 5);
    oledprint("Start an");
    cursor(1, 6);
    oledprint("interaction to");
    cursor(0, 7);
    oledprint("upload your data");
    
    char their_id[7];
    memset(&their_id, 0, 7);
    
    int t = CNT;
    char i_type[5];
    
    irscan("%s%s", their_id, i_type);
    
    if (strlen(their_id) > 0)
    {
      clear();
      eeprint("%s,%u,%s\n", their_id, 0, "INFO");
      irprint("%s\n%s\n", "htspt1", "DUMP");
      
      text_size(SMALL);
      cursor(2, 2);
      oledprint("Receiving...");
      
      while(1)
      {
        char b[128];
        memset(&b, 0, 128);
        irscan("%s", b);
        
        if (CNT - t > CLKLIMIT)
        {
          clear();
          text_size(LARGE);
          cursor(0, 0);
          oledprint(" ERROR");
          text_size(SMALL);
          cursor(0, 6);
          oledprint("Please try again");
          dprint(port, "txBegin\n");  
          dprint(port, "Timeout\n");
          contacts_clearAll();
          preserve_header();
          talk_say(spkr, "oops;/trae,-ugen");
          pause(2000);
          clear();
          break;
        }
        if (strlen(b) > 0)
        {
          t = CNT;
          if(!strcmp(b, "irDone"))
          {
            clear();
            text_size(LARGE);
            cursor(0, 0);
            oledprint("SUCCESS");
            text_size(SMALL);
            cursor(0, 6);
            oledprint("Upload complete");
            talk_say(spkr, "oakay;</aem,dun");
            dprint(port, "txBegin\n");
            upload_contacts(port);
            contacts_clearAll();
            preserve_header();
            pause(1000);
            clear();
            break;
          }
          save_contact(b); 
        }
      }        
    }      
  }    
}