| Total Complexity | 5 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package org.usfirst.frc.team3695.robot.subsystems; |
||
| 9 | public class SubsystemArduino extends Subsystem {
|
||
| 10 | |||
| 11 | I2C i2c; |
||
| 12 | byte[] toSend; |
||
| 13 | |||
| 14 | protected void initDefaultCommand() {}
|
||
| 15 | |||
| 16 | public SubsystemArduino() {
|
||
| 17 | i2c = new I2C(I2C.Port.kOnboard, Constants.I2C_DEVICE_ADDRESS); |
||
| 18 | toSend = new byte[1]; |
||
| 19 | // test(); |
||
| 20 | } |
||
| 21 | |||
| 22 | void test(){
|
||
| 23 | while (true){
|
||
| 24 | toSend[0] = 76; |
||
|
|
|||
| 25 | i2c.transaction(toSend, 1, null, 0); |
||
| 26 | Timer.delay(1); |
||
| 27 | toSend[0] = 72; |
||
| 28 | i2c.transaction(toSend, 1, null, 0); |
||
| 29 | Timer.delay(1); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | public void redline() {
|
||
| 34 | |||
| 40 | } |
Using constants for hard-coded numbers is a best practice. A constant’s name can explain the rationale behind this magic number. It is also easier to find if you ever need to change it.