Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Firmware/FFBoard/UserExtensions/Inc/SPIButtons.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SPI_Buttons: public ButtonSource,public CommandHandler,public SPIDevice {

const uint8_t maxButtons = 64;
std::string printModes(const std::vector<std::string>& names);
std::string printSpeeds(const std::vector<std::string>& names);

void setMode(SPI_BtnMode mode);
void initSPI();
Expand Down
16 changes: 13 additions & 3 deletions Firmware/FFBoard/UserExtensions/Src/SPIButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,18 @@ uint8_t SPI_Buttons::readButtons(uint64_t* buf){

std::string SPI_Buttons::printModes(const std::vector<std::string>& names){
std::string reply;
for(uint8_t i = 0; i<names.size();i++){
reply+= names[i] + ":" + std::to_string(i)+"\n";
for(uint8_t i = 0; i < names.size(); ++i){
reply += names[i] + ": " + std::to_string(i) + "\n";
}
return reply;
}

std::string SPI_Buttons::printSpeeds(const std::vector<std::string>& names){
std::string reply;
for(uint8_t i = 0; i < names.size(); ++i){
reply += names[i] + ": " +
std::to_string(this->speedPresets[i]) + " (" +
std::to_string(spiPort.getBaseClk() / (double)this->speedPresets[i]) + " Hz)\n";
}
return reply;
}
Expand Down Expand Up @@ -253,7 +263,7 @@ CommandStatus SPI_Buttons::command(const ParsedCommand& cmd,std::vector<CommandR
}else if(cmd.type == CMDtype::get){
replies.emplace_back((uint8_t)this->conf.spi_speed);
}else if(cmd.type == CMDtype::info){
replies.emplace_back(printModes(this->speed_names));
replies.emplace_back(printSpeeds(this->speed_names));
}else{
return CommandStatus::ERR;
}
Expand Down