fugu's CERICA board library. it is use 2019 robocon

Dependencies:   ST7032 QEI PS4Serial

Dependents:   2021Arobo_UMAPYOI 2021Arobo_YUMIPYOI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cerica2.h Source File

cerica2.h

00001 #pragma once
00002 
00003 #include "mbed.h"
00004 #include "QEI.h"
00005 enum WireSel {FEP01,TweLite};
00006 
00007 class CERICA
00008 {
00009 private:
00010     DigitalOut wireSelect;
00011     I2C i2c;
00012     PwmOut buz;
00013     BusOut leds;
00014     BusIn sw;
00015     DigitalOut dReset;
00016     QEI xEnc;
00017     QEI yEnc;
00018 
00019     char ADDR;
00020     bool brake;
00021     bool isEnc;
00022     long map(long x, long in_min, long in_max, long out_min, long out_max);
00023     char configData;
00024     char Div;
00025     //int minSpd;
00026     int maxSpd;
00027 
00028 public:
00029     CERICA(I2C *i2c_,WireSel WireSel_);
00030 
00031     // Board LED
00032     bool LED(int n_,bool l_);
00033 
00034     // Board SW
00035     bool SW(int n_)
00036     {
00037         return (~sw >> n_) & 0x1;
00038     }
00039 
00040     // Motor
00041     bool Send(bool available_ = 1);
00042     void Motor(char sendChannel,int verocity)
00043     {
00044         power[sendChannel] = verocity;
00045     }
00046     void maxRange(int maxSpd_)
00047     {
00048         maxSpd = maxSpd_;
00049     }
00050     void Set(bool isEnc_ = false,bool brake_ = false)
00051     {
00052         brake = brake_, isEnc = isEnc_;
00053     }
00054 
00055 
00056     // Speaker
00057     void Play(int scale_); // scale = 0 : C0
00058     void Stop()
00059     {
00060         buz = 0;
00061     }
00062 
00063     // Encoder
00064     int GetX()
00065     {
00066         return xEnc.getPulses();
00067     }
00068     int GetY()
00069     {
00070         return yEnc.getPulses();
00071     }
00072     void ResetX()
00073     {
00074         return xEnc.reset();
00075     }
00076     void ResetY()
00077     {
00078         return yEnc.reset();
00079     }
00080 
00081     //bool init(char toMD , bool rvs = false , bool omni = true, bool sound  = false , frequency freq = F256, int channel_ = 0);
00082 
00083     bool RawMotor(char sendChannel,int verocity);
00084     bool wait(int waitT);
00085 
00086     bool SystemReset(char sendChannel);
00087     bool ConfigReset(char sendChannel);
00088     bool DscOn(char sendChannel,bool mode);
00089     bool OutputFlip(char sendChannel,bool mode);
00090     bool DscPortOpen(char sendChannel,bool mode);
00091     bool SoundOn(char sendChannel,bool mode);
00092     bool SetDivider(char sendChannel,char pulse);
00093     /*void SetSpeedLimit(int min, int max)
00094     {
00095         minSpd = min;
00096         maxSpd = max;
00097     }*/
00098     int powerOut[16];
00099     int power[16];
00100 };