Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt
main.cpp
- Committer:
 - vsoltan
 - Date:
 - 2020-11-10
 - Revision:
 - 12:91affff3be75
 - Parent:
 - 11:d0a105f6743f
 - Child:
 - 13:95d44f7855ca
 
File content as of revision 12:91affff3be75:
#include "mbed.h"
#include "EthernetInterface.h"
#include "network.h"
#include "PinDetect.h"
#define DEBOUNCE 100
PinDetect leftButton(p21);
PinDetect middleButton(p22);
PinDetect rightButton(p23);
EthernetInterface eth; 
UDPSocket sock; 
Endpoint nist; 
// interrupt service routines 
void pressLeft() {
    printf("EYYYY BALL DO YOU WANNA GO BALLROOM\n");
    //char json[] = "{\"type\": \"move\", \"dir\": \"left\"}"; 
//    sock.sendTo(nist, json, sizeof(json) - 1);
}
void pressMiddle() {
    //char json[] = "{\"type\": \"move\", \"dir\": \"middle\"}"; 
//    sock.sendTo(nist, json, sizeof(json) - 1);
}
void pressRight() {
    //char json[] = "{\"type\": \"move\", \"dir\": \"right\"}"; 
//    sock.sendTo(nist, json, sizeof(json) - 1);
}
 
int main() {
    initEthernet(ð, &sock, &nist); 
    
    // initialize GPIO
    leftButton.mode(PullUp);
    middleButton.mode(PullUp);
    rightButton.mode(PullUp);
    
    // Delay for initial pullup to take effect
    wait(0.1); 
    
    leftButton.attach_deasserted(&pressLeft); 
    middleButton.attach_deasserted(&pressMiddle);
    rightButton.attach_deasserted(&pressRight);
    
    leftButton.setSampleFrequency(DEBOUNCE); 
    middleButton.setSampleFrequency(DEBOUNCE); 
    rightButton.setSampleFrequency(DEBOUNCE); 
    
    while(1) {}
    cleanupEthernet(ð, &sock);
}
            
    