Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete rewrite #13

Merged
merged 23 commits into from
Feb 27, 2017
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Converted input_types word set to HashedWord arr
  • Loading branch information
ashtuchkin committed Feb 20, 2017
commit caa8e02747b7d8a991b03d85698e49aa697bc22e
11 changes: 7 additions & 4 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ void InputNode::debug_print(Print& stream) {
#include "Print.h"
#include "primitives/string_utils.h"

uint32_t input_type_hashes[kInputTypeCount] = {"cmp"_hash, "ftm"_hash, "port_irq"_hash};
const char *input_type_names[kInputTypeCount] = {"cmp", "ftm", "port_irq"};
HashedWord input_types[kInputTypeCount] = {
[(int)InputType::kCMP] = { "cmp", "cmp"_hash },
[(int)InputType::kFTM] = { "ftm", "ftm"_hash },
[(int)InputType::kPort] = { "port_irq", "port_irq"_hash },
};

void InputDef::print_def(uint32_t idx, Print &stream) {
stream.printf("sensor%d pin %d %s %s", idx, pin, pulse_polarity ? "positive" : "negative", input_type_names[(int)input_type]);
stream.printf("sensor%d pin %d %s %s", idx, pin, pulse_polarity ? "positive" : "negative", input_types[(int)input_type].word);
if (input_type == InputType::kCMP)
stream.printf(" %d", initial_cmp_threshold);
stream.println();
Expand All @@ -86,7 +89,7 @@ bool InputDef::parse_def(uint32_t idx, HashedWord *input_words, Print &err_strea
} else {
int i;
for (i = 0; i < kInputTypeCount; i++)
if (*input_words == input_type_hashes[i]) {
if (*input_words == input_types[i]) {
input_type = (InputType)i;
break;
}
Expand Down