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
cerica2.h@16:bba1ff6d196e, 2019-10-04 (annotated)
- Committer:
- Suzu Tomo
- Date:
- Fri Oct 04 12:10:08 2019 +0900
- Revision:
- 16:bba1ff6d196e
- Parent:
- 15:f2e702d0047c
- Child:
- 17:a5a5f1234eae
add Send Function and remove motor Function
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Suzutomo | 15:f2e702d0047c | 1 | #pragma once |
| Suzutomo | 0:a1d2ea7aa5c6 | 2 | |
| Suzutomo | 15:f2e702d0047c | 3 | #include "mbed.h" |
| Suzutomo | 15:f2e702d0047c | 4 | #include "QEI.h" |
| Suzutomo | 15:f2e702d0047c | 5 | |
| Suzutomo | 15:f2e702d0047c | 6 | enum WireSel {FEP01,TweLite}; |
| Suzutomo | 1:019a7d4201c2 | 7 | |
| Suzutomo | 0:a1d2ea7aa5c6 | 8 | class CERICA |
| Suzutomo | 0:a1d2ea7aa5c6 | 9 | { |
| Suzutomo | 0:a1d2ea7aa5c6 | 10 | private: |
| Suzutomo | 0:a1d2ea7aa5c6 | 11 | DigitalOut wireSelect; |
| Suzutomo | 15:f2e702d0047c | 12 | I2C i2c; |
| Suzutomo | 15:f2e702d0047c | 13 | PwmOut buz; |
| Suzutomo | 15:f2e702d0047c | 14 | BusOut leds; |
| Suzutomo | 15:f2e702d0047c | 15 | BusIn sw; |
| Suzutomo | 15:f2e702d0047c | 16 | DigitalOut dReset; |
| Suzutomo | 15:f2e702d0047c | 17 | QEI xEnc; |
| Suzutomo | 15:f2e702d0047c | 18 | QEI yEnc; |
| Suzutomo | 15:f2e702d0047c | 19 | |
| Suzutomo | 11:8fa43cb31f9b | 20 | char ADDR; |
| Suzutomo | 11:8fa43cb31f9b | 21 | bool brake; |
| Suzutomo | 11:8fa43cb31f9b | 22 | bool isEnc; |
| Suzutomo | 11:8fa43cb31f9b | 23 | long map(long x, long in_min, long in_max, long out_min, long out_max); |
| Suzutomo | 11:8fa43cb31f9b | 24 | char configData; |
| Suzutomo | 11:8fa43cb31f9b | 25 | char Div; |
| Suzutomo | 15:f2e702d0047c | 26 | //int minSpd; |
| Suzutomo | 11:8fa43cb31f9b | 27 | int maxSpd; |
| Suzutomo | 15:f2e702d0047c | 28 | |
| Suzutomo | 0:a1d2ea7aa5c6 | 29 | public: |
| Suzutomo | 15:f2e702d0047c | 30 | CERICA(WireSel WireSel_); |
| Suzutomo | 15:f2e702d0047c | 31 | |
| Suzutomo | 15:f2e702d0047c | 32 | // Board LED |
| Suzutomo | 15:f2e702d0047c | 33 | bool LED(int n_,bool l_); |
| Suzutomo | 15:f2e702d0047c | 34 | |
| Suzutomo | 15:f2e702d0047c | 35 | // Board SW |
| Suzutomo | 15:f2e702d0047c | 36 | bool SW(int n_) |
| Suzutomo | 15:f2e702d0047c | 37 | { |
| Suzutomo | 15:f2e702d0047c | 38 | return (~sw >> n_) & 0x1; |
| Suzutomo | 15:f2e702d0047c | 39 | } |
| Suzutomo | 15:f2e702d0047c | 40 | |
| Suzutomo | 15:f2e702d0047c | 41 | // Motor |
| Suzutomo | 15:f2e702d0047c | 42 | bool Send(bool available_ = 1); |
| Suzutomo | 15:f2e702d0047c | 43 | void Motor(char sendChannel,int verocity) |
| Suzutomo | 15:f2e702d0047c | 44 | { |
| Suzutomo | 15:f2e702d0047c | 45 | power[sendChannel] = verocity; |
| Suzutomo | 15:f2e702d0047c | 46 | } |
| Suzutomo | 15:f2e702d0047c | 47 | void maxRange(int maxSpd_) |
| Suzutomo | 15:f2e702d0047c | 48 | { |
| Suzutomo | 15:f2e702d0047c | 49 | maxSpd = maxSpd_; |
| Suzutomo | 15:f2e702d0047c | 50 | } |
| Suzutomo | 15:f2e702d0047c | 51 | void Set(bool isEnc_ = false,bool brake_ = false) |
| Suzutomo | 15:f2e702d0047c | 52 | { |
| Suzutomo | 15:f2e702d0047c | 53 | brake = brake_, isEnc = isEnc_; |
| Suzutomo | 15:f2e702d0047c | 54 | } |
| Suzutomo | 15:f2e702d0047c | 55 | |
| Suzutomo | 15:f2e702d0047c | 56 | |
| Suzutomo | 15:f2e702d0047c | 57 | // Speaker |
| Suzutomo | 15:f2e702d0047c | 58 | void Play(int scale_); // scale = 0 : C0 |
| Suzutomo | 15:f2e702d0047c | 59 | void Stop() |
| Suzutomo | 15:f2e702d0047c | 60 | { |
| Suzutomo | 15:f2e702d0047c | 61 | buz = 0; |
| Suzutomo | 15:f2e702d0047c | 62 | } |
| Suzutomo | 15:f2e702d0047c | 63 | |
| Suzutomo | 15:f2e702d0047c | 64 | // Encoder |
| Suzutomo | 15:f2e702d0047c | 65 | int GetX() |
| Suzutomo | 15:f2e702d0047c | 66 | { |
| Suzutomo | 15:f2e702d0047c | 67 | return xEnc.getPulses(); |
| Suzutomo | 15:f2e702d0047c | 68 | } |
| Suzutomo | 15:f2e702d0047c | 69 | int GetY() |
| Suzutomo | 15:f2e702d0047c | 70 | { |
| Suzutomo | 15:f2e702d0047c | 71 | return yEnc.getPulses(); |
| Suzutomo | 15:f2e702d0047c | 72 | } |
| Suzutomo | 15:f2e702d0047c | 73 | void ResetX() |
| Suzutomo | 15:f2e702d0047c | 74 | { |
| Suzutomo | 15:f2e702d0047c | 75 | return xEnc.reset(); |
| Suzutomo | 15:f2e702d0047c | 76 | } |
| Suzutomo | 15:f2e702d0047c | 77 | void ResetY() |
| Suzutomo | 15:f2e702d0047c | 78 | { |
| Suzutomo | 15:f2e702d0047c | 79 | return yEnc.reset(); |
| Suzutomo | 15:f2e702d0047c | 80 | } |
| Suzutomo | 15:f2e702d0047c | 81 | |
| Suzutomo | 11:8fa43cb31f9b | 82 | //bool init(char toMD , bool rvs = false , bool omni = true, bool sound = false , frequency freq = F256, int channel_ = 0); |
| Suzutomo | 15:f2e702d0047c | 83 | |
| Suzutomo | 11:8fa43cb31f9b | 84 | bool RawMotor(char sendChannel,int verocity); |
| Suzutomo | 11:8fa43cb31f9b | 85 | bool wait(int waitT); |
| Suzutomo | 15:f2e702d0047c | 86 | |
| Suzutomo | 11:8fa43cb31f9b | 87 | bool SystemReset(char sendChannel); |
| Suzutomo | 11:8fa43cb31f9b | 88 | bool ConfigReset(char sendChannel); |
| Suzutomo | 11:8fa43cb31f9b | 89 | bool DscOn(char sendChannel,bool mode); |
| Suzutomo | 11:8fa43cb31f9b | 90 | bool OutputFlip(char sendChannel,bool mode); |
| Suzutomo | 11:8fa43cb31f9b | 91 | bool DscPortOpen(char sendChannel,bool mode); |
| Suzutomo | 11:8fa43cb31f9b | 92 | bool SoundOn(char sendChannel,bool mode); |
| Suzutomo | 11:8fa43cb31f9b | 93 | bool SetDivider(char sendChannel,char pulse); |
| Suzutomo | 15:f2e702d0047c | 94 | /*void SetSpeedLimit(int min, int max) |
| Suzutomo | 15:f2e702d0047c | 95 | { |
| Suzutomo | 15:f2e702d0047c | 96 | minSpd = min; |
| Suzutomo | 15:f2e702d0047c | 97 | maxSpd = max; |
| Suzutomo | 15:f2e702d0047c | 98 | }*/ |
| Suzutomo | 11:8fa43cb31f9b | 99 | int powerOut[16]; |
| Suzutomo | 11:8fa43cb31f9b | 100 | int power[16]; |
| Suzutomo | 0:a1d2ea7aa5c6 | 101 | }; |