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.
pcinput.cpp@0:8c4ff7ea7eb9, 2021-03-01 (annotated)
- Committer:
- ijajcevic
- Date:
- Mon Mar 01 18:52:33 2021 +0000
- Revision:
- 0:8c4ff7ea7eb9
Projektni zadatak
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ijajcevic | 0:8c4ff7ea7eb9 | 1 | // input s tikovnice |
ijajcevic | 0:8c4ff7ea7eb9 | 2 | #include "pcinput.h" |
ijajcevic | 0:8c4ff7ea7eb9 | 3 | Serial pc(USBTX, USBRX); // komunikacija s recunalom |
ijajcevic | 0:8c4ff7ea7eb9 | 4 | void inicijalizacija(void) |
ijajcevic | 0:8c4ff7ea7eb9 | 5 | { |
ijajcevic | 0:8c4ff7ea7eb9 | 6 | pc.printf("\n\r Unesi vrjednost:\n\r"); |
ijajcevic | 0:8c4ff7ea7eb9 | 7 | } |
ijajcevic | 0:8c4ff7ea7eb9 | 8 | char KeyInput(void) |
ijajcevic | 0:8c4ff7ea7eb9 | 9 | { |
ijajcevic | 0:8c4ff7ea7eb9 | 10 | char c = pc.getc(); // dobivanje ulaza s tikovnice |
ijajcevic | 0:8c4ff7ea7eb9 | 11 | int uvijet; |
ijajcevic | 0:8c4ff7ea7eb9 | 12 | uvijet = c; |
ijajcevic | 0:8c4ff7ea7eb9 | 13 | if (uvijet < 48 ){ |
ijajcevic | 0:8c4ff7ea7eb9 | 14 | c = 48; |
ijajcevic | 0:8c4ff7ea7eb9 | 15 | } |
ijajcevic | 0:8c4ff7ea7eb9 | 16 | if (uvijet > 58){ |
ijajcevic | 0:8c4ff7ea7eb9 | 17 | c = 58; |
ijajcevic | 0:8c4ff7ea7eb9 | 18 | } |
ijajcevic | 0:8c4ff7ea7eb9 | 19 | pc.printf("%c",c); // isprintaj na teraterm |
ijajcevic | 0:8c4ff7ea7eb9 | 20 | return (c); // vrati vrijednost znaka |
ijajcevic | 0:8c4ff7ea7eb9 | 21 | } |