Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
Signed-off-by: Daisuke Sato <daisukes@cmu.edu>
  • Loading branch information
daisukes committed Aug 8, 2024
1 parent 77c36cf commit d8648c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CaBotHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ size_t Handle::readCommand(uint8_t * expect, uint8_t ** ptr)
if (state != 0 || received != 0) {
static char buff[48];
snprintf(
buff, 48, "%02x %d %d %x %x %d %d %d", received, state,
buff, sizeof(buff), "%02x %d %d %x %x %d %d %d", received, state,
header_count, cmd, *expect, size, size_count, count);
loginfo(buff);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ size_t Handle::readCommand(uint8_t * expect, uint8_t ** ptr)
if (size_count == DATA_MAX_SIZE_BYTE) {
if (size < 0 || sizeof(buffer) < size) {
state = 0;
snprintf(buff, 48, "size is too big cmd=%d, size=%d", cmd, size);
snprintf(buff, sizeof(buff), "size is too big cmd=%d, size=%d", cmd, size);
logwarn(buff);
return 0;
} else if (size == 0) {
Expand Down
15 changes: 8 additions & 7 deletions VibratorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ VibratorController::VibratorController(
vib_pin[2] = vib3_pin;
vib_pin[3] = vib4_pin;

ch.subscribe(0x20, [](const uint8_t msg) { instance->vibrations[0] = msg+1; });
ch.subscribe(0x21, [](const uint8_t msg) { instance->vibrations[1] = msg+1; });
ch.subscribe(0x22, [](const uint8_t msg) { instance->vibrations[2] = msg+1; });
ch.subscribe(0x23, [](const uint8_t msg) { instance->vibrations[3] = msg+1; });
ch.subscribe(0x20, [](const uint8_t msg) {instance->vibrations[0] = msg + 1;});
ch.subscribe(0x21, [](const uint8_t msg) {instance->vibrations[1] = msg + 1;});
ch.subscribe(0x22, [](const uint8_t msg) {instance->vibrations[2] = msg + 1;});
ch.subscribe(0x23, [](const uint8_t msg) {instance->vibrations[3] = msg + 1;});
}

void VibratorController::init()
{
for(int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
pinMode(vib_pin[i], OUTPUT);
analogWrite(vib_pin[i], 0);
}
}

void VibratorController::update() {
for(int i = 0; i < 4; i++) {
void VibratorController::update()
{
for (int i = 0; i < 4; i++) {
if (vibrations[i] > 0) {
if (vibrations[i] == 1) {
analogWrite(vib_pin[i], 0);
Expand Down

0 comments on commit d8648c2

Please sign in to comment.