Testing Linija
Dependencies: JoystickLinija IRremote mbed Tipkalo UniServ_linijapogona umotor_linijapogona
Revision 2:9d19b20a60a9, committed 2017-11-22
- Comitter:
- mario_meh
- Date:
- Wed Nov 22 08:54:16 2017 +0000
- Parent:
- 0:4cac97044e74
- Commit message:
- Linija pogona
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IRremote.lib Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yuhki50/code/IRremote/#c82a0d54a024
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/JoystickLinija.lib Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/mario_meh/code/JoystickLinija/#bdd4ee83ec25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tipkalo.lib Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/mario_meh/code/Tipkalo/#b9ab9a191011
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UniServ.lib Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mario_meh/code/UniServ_linijapogona/#74fdb2c8ae56
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/global_nazivi.h Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,37 @@ +/** +* Definirani globalni nazivi +*/ +#ifndef GLOBAL_NAZIVI_H +#define GLOBAL_NAZIVI_H + +// Linija pogona +typedef enum { + LINIJA_RADI = 0, LINIJA_STOP = 1, LINIJA_START = 2, LINIJA_MOTOR, +} LinijaPogona; + +// Joystick + +/* I2C */ +#define PIN_SCL PTE1 +#define PIN_SDA PTE0 +/* SPI */ +#define PIN_SCK PTD1 +#define PIN_MISO PTD3 +#define PIN_MOSI PTD2 +#define PIN_CS0 PTD0 +/* Interrupt */ +#define PIN_INT0 PTD5 +#define PIN_INT1 PTA13 +#define PIN_INT2 PTC9 /* This pin does not support interrupt */ +#define PIN_INT3 PTC8 /* This pin does not support interrupt */ +#define PIN_INT4 PTA5 +#define PIN_INT5 PTA4 +/* Analog Input */ +#define PIN_AN0 PTB0 +#define PIN_AN1 PTB1 +#define PIN_AN2 PTB2 +#define PIN_AN3 PTB3 +#define PIN_AN4 PTC2 +#define PIN_AN5 PTC1 + +#endif \ No newline at end of file
--- a/joystick.cpp Sun Jan 29 23:23:10 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#include "mbed.h" -#include "tipkalo.h" - -Joystick::Joystick() : _x(PTB0), _y(PTB1) - - // PTB0 | PTB1 -{ - - Tipkalo tjoys = new Tipkalo(PT); - -} - -JoysKompas Joystick::read() { - - JoysKompas data; - - data.horizontala = X(); - data.vertikala = Y(); - data.jTipkalo = t_status.radim; - return data; - -} - -//------------- KOMPAS NAV Y --- -----------/ -Kompas Joystick::Y() { - if(_y.read() < 0.022222222) { - return Dolje; - } else if(_y.read() > 0.9888888) { - return Gore; - } -} - -//------------- KOMPAS NAV X ---------------/ -Kompas Joystick::X() { - if(_x.read() < 0.022222222) { - return Lijevo; - } else if(_x.read() > 0.9888888) { - return Desno; - } -} - -//------------- KOMPAS TIPKA ---------------/ -Kompas tipka() { - if(tjoys->tDolje()) { - return NijeOdabir; - } else { - return Odabir; - } -} \ No newline at end of file
--- a/joystick.h Sun Jan 29 23:23:10 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#ifndef JOYSTICK_H -#define JOYSTICK_H - -#ifndef MBED_H -#include "mbed.h" -#endif -#ifndef GLOBAL_NAZIVI_H -#include "global_nazivi.h" -#endif - -typedef enum { - Gore=0,Dolje=1,Lijevo=2,Desno=3, Odabir=4, NijeOdabir = 5, -} Kompas; - -struct JoysKompas { - double horizontala; - double vertikala; - int jTipkalo; -}; - -class Joystick { - public: - Joystick(); - // Podijelio joystick na dvije f-je os X i os Y - Kompas X(); - Kompas Y(); - Kompas tipka(); - // - JoysKompas read(); - private: - int size; - AnalogIn _x; - AnalogIn _y; -}; \ No newline at end of file
--- a/main.cpp Sun Jan 29 23:23:10 2017 +0000 +++ b/main.cpp Wed Nov 22 08:54:16 2017 +0000 @@ -1,22 +1,72 @@ +/** Projektiranje ugradbenih računalnih sustava +* Interakcija sa linijom +* @author: mario_meh +* +*/ #include "mbed.h" +#include "tipkalo.h" +#include "joystick.h" #include "IRremote.h" +#include "UniServ.h" +#include "umotor.h" Serial serial(USBTX, USBRX); // PC -IRrecv pinIn(PTA5); // IR +DigitalOut led(PTB19); +IRrecv pinIn(PTB3); // IR I2C i2c(PTC9, PTC8); // SDA, SCL //Tipkalo led(PT); // LED svjetlo +UniServ sMotor(PTB2); +Timer t; +Serial pc(USBTX, USBRX); // tx, rx + const int addr = 0x0A; -uint8_t result[4]; +char remote[4]; int main() { - + //--------------------------------------------------tipke pogona - //Tipkalo start = new Tipkalo(PT); - //Tipkalo stop = new Tipkalo(PT); - //Tipkalo lcd = new Tipkalo(PT); + Tipkalo *bTipka = new Tipkalo(); //--------------------------------------------------IR argumenti + + //--------------------------------------------------Provjera Servo C90 + t.start(); + sMotor.write_us(2000); + t.stop(); + pc.printf("%f\n\r", t.read()); + wait_ms(1000); + t.reset(); + t.start(); + sMotor.write_us(0); + t.stop(); + pc.printf("%f\n\r", t.read()); + wait_ms(1000); + t.reset(); + t.start(); + sMotor.write_us(3000); + t.stop(); + pc.printf("%f\n\r", t.read()); + wait_ms(1000); + t.reset(); + t.start(); + sMotor.write_us(1000); + t.stop(); + pc.printf("%f\n\r", t.read()); + wait_ms(1000); + sMotor.Disable(); + //-------------------------------------------------Gotovo Provjera Servo C90 + + //--------------------------------------------------Unipolarni steper + Steper *unipolar = new Steper(); + + unipolar->u_poz.u_krenuo = 1; // Treba biti 1(0) + unipolar->u_poz.u_stao = 0; // Treba biti 0(1) + unipolar->Brzina(4000); // < brzina = brze i krace + unipolar->UEnable(); // Pokreni umotor + //--------------------------------------------------Gotovo Unipolarni steper + + //-------------------------------------------------- IR Receiver pinIn.enableIRIn(); // Start the receiver decode_results results; @@ -39,27 +89,27 @@ //------------------------------------------isprobavam joystick // Pozovi Joystick - Joystick *joys = new Joystick; - // Aktivan ručni mod - int LCD_SELECTED = 1; - //int BUTTON = 1; - while(LCD_SELECTED == 1) { - switch(joys->Y()) { + JoysKompas *data = new JoysKompas; + Joystick *joys = new Joystick(data); + joys->YEnable(); + + while(1) { + switch(data->vertikala) { case 0: - serial.printf("Gore: %i\r\n", joys->Y()); + serial.printf("Gore: %i\r\n", data->vertikala); break; case 1: - serial.printf("Dolje: %i\r\n", joys->Y()); + serial.printf("Dolje: %i\r\n", data->vertikala); break; - case 4: - serial.printf("Odabir: %i\r\n", joys->tipka()); - } + } + } + //----------------------------------------------gotov joystick //-----------------------------------------------------svjetlo //led = 1; //-------------------------------------------------end svjetlo -} +} \ No newline at end of file
--- a/tipkalo.cpp Sun Jan 29 23:23:10 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#include "mbed.h" -#include "tipkalo.h" - -Tipkalo::Tipkalo(PinName T) : _T(T), _countT(0) { - - t_status status = new t_status; - - Tipkalo::t_status.tiskljucen = TDOLJE; - _T.fall(this, &Tipkalo::tDolje); - - Timer.debounce; - debounce.start(); -} - -t_status Tipkalo::tDolje() { - - status.radim = TDOLJE; - _countT++; - status.pritisnut = _countT; - return TGORE; - -} - - - - - - \ No newline at end of file
--- a/tipkalo.h Sun Jan 29 23:23:10 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -#ifndef TIPKALO_H -#define TIPKALO_H - -#define t_milisec_pritisnut = 200; - -typedef enum { - TDOLJE = 1, TGORE = 0, TNEZNAM = -1 -}; - -typedef struct t_status { - int radim; // tukljucen ili tiskljucen - int pritisnut; -} t_status; - - -//---------------TIPKALO------------------// -class Tipkalo { - public: - Tipkalo(PinName T); - t_status tDolje(); - private: - InterruptIn _T; - int _countT; -}; - -//-----------TIPKALO JOYSTICK-------------// -// To je zapravo TIPKALO - -#endif /* TIPKALO_H */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/umotor.lib Wed Nov 22 08:54:16 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mario_meh/code/umotor_linijapogona/#b769f13c7523