Skip to content

Commit 6002a6d

Browse files
committed
Make SPI command spispeed more verbose
1 parent 1dc7028 commit 6002a6d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class SPI_Buttons: public ButtonSource,public CommandHandler,public SPIDevice {
5555

5656
const uint8_t maxButtons = 64;
5757
std::string printModes(const std::vector<std::string>& names);
58+
std::string printSpeeds(const std::vector<std::string>& names);
5859

5960
void setMode(SPI_BtnMode mode);
6061
void initSPI();

Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,18 @@ uint8_t SPI_Buttons::readButtons(uint64_t* buf){
193193

194194
std::string SPI_Buttons::printModes(const std::vector<std::string>& names){
195195
std::string reply;
196-
for(uint8_t i = 0; i<names.size();i++){
197-
reply+= names[i] + ":" + std::to_string(i)+"\n";
196+
for(uint8_t i = 0; i < names.size(); ++i){
197+
reply += names[i] + ": " + std::to_string(i) + "\n";
198+
}
199+
return reply;
200+
}
201+
202+
std::string SPI_Buttons::printSpeeds(const std::vector<std::string>& names){
203+
std::string reply;
204+
for(uint8_t i = 0; i < names.size(); ++i){
205+
reply += names[i] + ": " +
206+
std::to_string(this->speedPresets[i]) + " (" +
207+
std::to_string(spiPort.getBaseClk() / (double)this->speedPresets[i]) + " Hz)\n";
198208
}
199209
return reply;
200210
}
@@ -253,7 +263,7 @@ CommandStatus SPI_Buttons::command(const ParsedCommand& cmd,std::vector<CommandR
253263
}else if(cmd.type == CMDtype::get){
254264
replies.emplace_back((uint8_t)this->conf.spi_speed);
255265
}else if(cmd.type == CMDtype::info){
256-
replies.emplace_back(printModes(this->speed_names));
266+
replies.emplace_back(printSpeeds(this->speed_names));
257267
}else{
258268
return CommandStatus::ERR;
259269
}

0 commit comments

Comments
 (0)