This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
lokos [2019/05/30 05:53] 2480 |
lokos [2019/10/23 21:11] (current) |
||
---|---|---|---|
Line 53: | Line 53: | ||
int main() { | int main() { | ||
- | printf("Hello World!"); | + | printf("Hello World!\n"); |
} | } | ||
</code> | </code> | ||
Line 326: | Line 326: | ||
- | ====== Αποτελέσματα ====== | + | ===== Αποτελέσματα ===== |
{{2a.jpg}} | {{2a.jpg}} | ||
Line 337: | Line 337: | ||
- | γ) Για το γ ερώτημα χρειαζόματε τα εξής βήματα: | + | γ) Για το γ ερώτημα κάναμε κάποιες τροποποιήσεις. Δημιουργήσαμε μια συνάρτηση pressed η οποία είναι συνδεδεμένη με ενα από τα onboard button και είναι καταχωρημένο ως interruptIn. Στη main καλούμε τη συνάρτηση dhrystoneBenchmark() |
- | - Δημιουργία ξεχωριστών συναρτήσεων. | + | η οποία εκτελεί το benchmark και στη διάρκεια αυτής της εκτέλεσης πατούσαμε αρκετές φορές το interrupt button βλέποντας ταυτόχρονα την φωτεινή ένδειξη να ανάβει και να σβήνει κάθε φορά που καλούταν η pressed. |
Line 349: | Line 349: | ||
Serial pc(USBTX, USBRX); //serial channel over HDK USB interface | Serial pc(USBTX, USBRX); //serial channel over HDK USB interface | ||
InterruptIn btn(SW2); | InterruptIn btn(SW2); | ||
+ | |||
+ | |||
+ | AnalogIn potentiometer(A3); | ||
+ | DigitalOut led(LED2); | ||
+ | |||
+ | void pressed(){ | ||
+ | | ||
+ | if (led) | ||
+ | led = 0; | ||
+ | else | ||
+ | led = 1; | ||
+ | } | ||
void dhrystoneBenchmark(){ | void dhrystoneBenchmark(){ | ||
+ | | ||
double benchtime, dps; | double benchtime, dps; | ||
unsigned long loops; | unsigned long loops; | ||
Line 365: | Line 378: | ||
printf("Dhrystone Benchmark Program C/1 12/01/84\r\n"); | printf("Dhrystone Benchmark Program C/1 12/01/84\r\n"); | ||
timer.start(); | timer.start(); | ||
+ | | ||
while(1) { | while(1) { | ||
loops = 0l; | loops = 0l; | ||
Line 394: | Line 408: | ||
| | ||
} | } | ||
- | |||
- | |||
- | AnalogIn potentiometer(A3); | ||
- | DigitalOut red(D7); | ||
- | |||
- | void runPotentiometer(){ | ||
- | float potValue; | ||
- | | ||
- | |||
- | potValue = potentiometer.read(); | ||
- | | ||
- | red = 1; | ||
- | wait(int (potValue*100) ); | ||
- | red = 0; | ||
- | |||
- | } | ||
- | |||
int main() { | int main() { | ||
- | dhrystoneBenchmark(); | + | dhrystoneBenchmark(); |
- | btn.fall(&runPotentiometer); | + | btn.fall(&pressed); |
| | ||
} | } | ||
- | |||
</code> | </code> | ||
+ | |||
+ | |||
+ | ===== Αποτελέσματα ===== | ||
+ | |||
+ | |||
+ | |||
+ | Τα αποτελέσματα που πήραμε ήταν παράδοξα καθώς τα νούμερα ήταν μεγαλύτερα απο το ερώτημα 2α. | ||
+ | {{23.jpg}} | ||
====== Project Μέρος 3 ====== | ====== Project Μέρος 3 ====== | ||
+ | |||
+ | |||
+ | Αρχικός στόχος μας ήταν η δημιουργία μιας εφαρμογής στην οποία θα μπορούσαμε να εξοικειωθούμε με την χρήση της θύρας ethernet καθώς με διάφορα περιφερειακά με τα οποία θα μπορούσαμε να είχαμε αλληλεπίδραση με το χρήστη. | ||
+ | |||
+ | Η εφαρμογή η οποία δημιουργήσαμε αποστέλει ενα HTTP request στην ιστοσελίδα openweathermap.org με την δυνατότητα ο χρήστης να επιλέξει την πόλη την οποία επιθυμεί. Στη συνέχεια διαχωρίζουμε τα δεδομένα τα οποία δεχτήκαμε και εκτυπώνουμε αυτά τα οποία έχουμε προεπιλέξει. | ||
+ | |||
+ | Για την εφαρμογή χρησιμοποιήσαμε την βιβλιοθήκη **mbed-http** | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Line 447: | Line 464: | ||
| | ||
} | } | ||
+ | printf("\nBody (%d bytes):\n\n%s\n", res->get_body_length(), res->get_body_as_string().c_str()); | ||
| | ||
} | } | ||
Line 477: | Line 495: | ||
int main() { | int main() { | ||
printf("Program Starting..\n"); | printf("Program Starting..\n"); | ||
+ | | ||
// Connect to the network with the default networking interface | // Connect to the network with the default networking interface | ||
- | | ||
NetworkInterface* network = connect_to_default_network_interface(); | NetworkInterface* network = connect_to_default_network_interface(); | ||
Line 486: | Line 504: | ||
// By default the body is automatically parsed and stored in a buffer, this is memory heavy. | // By default the body is automatically parsed and stored in a buffer, this is memory heavy. | ||
// To receive chunked response, pass in a callback as last parameter to the constructor. | // To receive chunked response, pass in a callback as last parameter to the constructor. | ||
- | |||
| | ||
- | //char request = "http://api.openweathermap.org/data/2.5/forecast?"+city+"&cnt=1&APPID=3ff29328f7c661abef83a312168bc559"; | + | HttpRequest* get_req = new HttpRequest(network, HTTP_GET, "http://api.openweathermap.org/data/2.5/weather?q=Ioannina&units=metric&APPID=3ff29328f7c661abef83a312168bc559"); |
- | HttpRequest* get_req = new HttpRequest(network, HTTP_GET, "http://api.openweathermap.org/data/2.5/forecast?q=Ioannina&cnt=1&APPID=3ff29328f7c661abef83a312168bc559"); | + | |
| | ||
HttpResponse* get_res = get_req->send(); | HttpResponse* get_res = get_req->send(); | ||
Line 503: | Line 519: | ||
} | } | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
wait(osWaitForever); | wait(osWaitForever); | ||
} | } | ||
Line 516: | Line 525: | ||
</code> | </code> | ||
+ | ===== Αποτελέσματα ===== | ||
+ | {{output.jpg}} | ||