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: ST7032 QEI PS4Serial
Dependents: 2021Arobo_UMAPYOI 2021Arobo_YUMIPYOI
Diff: cerica2.h
- Revision:
- 15:f2e702d0047c
- Parent:
- 13:91a699eae3ea
- Child:
- 16:bba1ff6d196e
--- a/cerica2.h Mon Aug 19 01:33:19 2019 +0000
+++ b/cerica2.h Wed Sep 18 07:51:42 2019 +0000
@@ -1,35 +1,90 @@
-#include "mbed.h"
+#pragma once
-enum WireSel {
- FEP01,TweLite
-};
+#include "mbed.h"
+#include "QEI.h"
+
+enum WireSel {FEP01,TweLite};
class CERICA
{
private:
DigitalOut wireSelect;
-
- I2C *i2c;
+ I2C i2c;
+ PwmOut buz;
+ BusOut leds;
+ BusIn sw;
+ DigitalOut dReset;
+ QEI xEnc;
+ QEI yEnc;
+
char ADDR;
bool brake;
bool isEnc;
- bool channel;
long map(long x, long in_min, long in_max, long out_min, long out_max);
char configData;
char Div;
- int minSpd;
+ //int minSpd;
int maxSpd;
-
+
public:
- CERICA(I2C *i2c_,WireSel WireSel_);
-
+ CERICA(WireSel WireSel_);
+
+ // Board LED
+ bool LED(int n_,bool l_);
+
+ // Board SW
+ bool SW(int n_)
+ {
+ return (~sw >> n_) & 0x1;
+ }
+
+ // Motor
+ bool Send(bool available_ = 1);
+ void Motor(char sendChannel,int verocity)
+ {
+ power[sendChannel] = verocity;
+ }
+ void maxRange(int maxSpd_)
+ {
+ maxSpd = maxSpd_;
+ }
+ void Set(bool isEnc_ = false,bool brake_ = false)
+ {
+ brake = brake_, isEnc = isEnc_;
+ }
+
+
+ // Speaker
+ void Play(int scale_); // scale = 0 : C0
+ void Stop()
+ {
+ buz = 0;
+ }
+
+ // Encoder
+ int GetX()
+ {
+ return xEnc.getPulses();
+ }
+ int GetY()
+ {
+ return yEnc.getPulses();
+ }
+ void ResetX()
+ {
+ return xEnc.reset();
+ }
+ void ResetY()
+ {
+ return yEnc.reset();
+ }
+
//bool init(char toMD , bool rvs = false , bool omni = true, bool sound = false , frequency freq = F256, int channel_ = 0);
- void mRange(int minSpd_,int maxSpd_);
- bool motor(bool available_ = 1);
- void motor(char sendChannel,int verocity);
+
+ //bool motor(bool available_ = 1);
bool RawMotor(char sendChannel,int verocity);
bool wait(int waitT);
- void set(bool isEnc_ = false,bool brake_ = false,int channel_ = 0);
+
bool SystemReset(char sendChannel);
bool ConfigReset(char sendChannel);
bool DscOn(char sendChannel,bool mode);
@@ -37,7 +92,11 @@
bool DscPortOpen(char sendChannel,bool mode);
bool SoundOn(char sendChannel,bool mode);
bool SetDivider(char sendChannel,char pulse);
- void SetSpeedLimit(int min, int max){ minSpd = min; maxSpd = max; }
+ /*void SetSpeedLimit(int min, int max)
+ {
+ minSpd = min;
+ maxSpd = max;
+ }*/
int powerOut[16];
int power[16];
};
\ No newline at end of file