Fixes some issues with sounds and the appropriate factory. Further moved the calculation of pin addresses with pin base into the factories
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
"port_extenders" :
|
"port_extenders" :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name" : "extender_0",
|
|
||||||
"i2c_address" : 34,
|
"i2c_address" : 34,
|
||||||
|
"name" : "extender_0",
|
||||||
"pin_base" : 81
|
"pin_base" : 81
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -13,339 +13,321 @@
|
|||||||
"address" : 13,
|
"address" : 13,
|
||||||
"extender" : "extender_0"
|
"extender" : "extender_0"
|
||||||
},
|
},
|
||||||
"address_pins" : [ 15, 14, 12, 10, 8, 9, 11 ],
|
"address_pins" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id" : 0,
|
||||||
|
"address" : 15,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 1,
|
||||||
|
"address" : 14,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 2,
|
||||||
|
"address" : 12,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 3,
|
||||||
|
"address" : 10,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 4,
|
||||||
|
"address" : 8,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 5,
|
||||||
|
"address" : 9,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 6,
|
||||||
|
"address" : 11,
|
||||||
|
"extender" : "extender_0"
|
||||||
|
}
|
||||||
|
],
|
||||||
"sounds" :
|
"sounds" :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id" : 0,
|
"id" : 0,
|
||||||
"address" : 22,
|
"address" : 22,
|
||||||
"name" : "Sound 1",
|
"name" : "Sound 1",
|
||||||
"extender" : "extender_0",
|
|
||||||
"deactivation_time_milliseconds" : 10
|
"deactivation_time_milliseconds" : 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
"address" : 23,
|
"address" : 23,
|
||||||
"name" : "Sound 2",
|
"name" : "Sound 2"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 2,
|
"id" : 2,
|
||||||
"address" : 24,
|
"address" : 24,
|
||||||
"name" : "Sound 3",
|
"name" : "Sound 3"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 3,
|
"id" : 3,
|
||||||
"address" : 25,
|
"address" : 25,
|
||||||
"name" : "Sound 4",
|
"name" : "Sound 4"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 4,
|
"id" : 4,
|
||||||
"address" : 26,
|
"address" : 26,
|
||||||
"name" : "Sound 5",
|
"name" : "Sound 5"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 5,
|
"id" : 5,
|
||||||
"address" : 27,
|
"address" : 27,
|
||||||
"name" : "Sound 6",
|
"name" : "Sound 6"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 6,
|
"id" : 6,
|
||||||
"address" : 28,
|
"address" : 28,
|
||||||
"name" : "Sound 7",
|
"name" : "Sound 7"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 7,
|
"id" : 7,
|
||||||
"address" : 29,
|
"address" : 29,
|
||||||
"name" : "Sound 8",
|
"name" : "Sound 8"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 8,
|
"id" : 8,
|
||||||
"address" : 30,
|
"address" : 30,
|
||||||
"name" : "Sound 9",
|
"name" : "Sound 9"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 9,
|
"id" : 9,
|
||||||
"address" : 31,
|
"address" : 31,
|
||||||
"name" : "Sound 10",
|
"name" : "Sound 10"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 10,
|
"id" : 10,
|
||||||
"address" : 32,
|
"address" : 32,
|
||||||
"name" : "Sound 11",
|
"name" : "Sound 11"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 11,
|
"id" : 11,
|
||||||
"address" : 33,
|
"address" : 33,
|
||||||
"name" : "Sound 12",
|
"name" : "Sound 12"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 12,
|
"id" : 12,
|
||||||
"address" : 34,
|
"address" : 34,
|
||||||
"name" : "Sound 13",
|
"name" : "Sound 13"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 13,
|
"id" : 13,
|
||||||
"address" : 35,
|
"address" : 35,
|
||||||
"name" : "Sound 14",
|
"name" : "Sound 14"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 14,
|
"id" : 14,
|
||||||
"address" : 36,
|
"address" : 36,
|
||||||
"name" : "Sound 15",
|
"name" : "Sound 15"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 15,
|
"id" : 15,
|
||||||
"address" : 37,
|
"address" : 37,
|
||||||
"name" : "Sound 16",
|
"name" : "Sound 16"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 16,
|
"id" : 16,
|
||||||
"address" : 38,
|
"address" : 38,
|
||||||
"name" : "Sound 17",
|
"name" : "Sound 17"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 17,
|
"id" : 17,
|
||||||
"address" : 39,
|
"address" : 39,
|
||||||
"name" : "Sound 18",
|
"name" : "Sound 18"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 18,
|
"id" : 18,
|
||||||
"address" : 40,
|
"address" : 40,
|
||||||
"name" : "Sound 19",
|
"name" : "Sound 19"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 19,
|
"id" : 19,
|
||||||
"address" : 41,
|
"address" : 41,
|
||||||
"name" : "Sound 20",
|
"name" : "Sound 20"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 20,
|
"id" : 20,
|
||||||
"address" : 42,
|
"address" : 42,
|
||||||
"name" : "Sound 21",
|
"name" : "Sound 21"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 21,
|
"id" : 21,
|
||||||
"address" : 43,
|
"address" : 43,
|
||||||
"name" : "Sound 22",
|
"name" : "Sound 22"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 22,
|
"id" : 22,
|
||||||
"address" : 44,
|
"address" : 44,
|
||||||
"name" : "Sound 23",
|
"name" : "Sound 23"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 23,
|
"id" : 23,
|
||||||
"address" : 45,
|
"address" : 45,
|
||||||
"name" : "Sound 24",
|
"name" : "Sound 24"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 24,
|
"id" : 24,
|
||||||
"address" : 46,
|
"address" : 46,
|
||||||
"name" : "Sound 25",
|
"name" : "Sound 25"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 25,
|
"id" : 25,
|
||||||
"address" : 47,
|
"address" : 47,
|
||||||
"name" : "Sound 26",
|
"name" : "Sound 26"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 26,
|
"id" : 26,
|
||||||
"address" : 48,
|
"address" : 48,
|
||||||
"name" : "Sound 27",
|
"name" : "Sound 27"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 27,
|
"id" : 27,
|
||||||
"address" : 49,
|
"address" : 49,
|
||||||
"name" : "Sound 28",
|
"name" : "Sound 28"
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 28,
|
"id" : 28,
|
||||||
"address" : 50,
|
"address" : 50,
|
||||||
"name" : "Speech 1: \"You're good! But I'm still the Champ!\"",
|
"name" : "Speech 1: \"You're good! But I'm still the Champ!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 29,
|
"id" : 29,
|
||||||
"address" : 51,
|
"address" : 51,
|
||||||
"name" : "Speech 2: \"Twenty\"",
|
"name" : "Speech 2: \"Twenty\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 30,
|
"id" : 30,
|
||||||
"address" : 52,
|
"address" : 52,
|
||||||
"name" : "Speech 3: \"Seconds\"",
|
"name" : "Speech 3: \"Seconds\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 31,
|
"id" : 31,
|
||||||
"address" : 53,
|
"address" : 53,
|
||||||
"name" : "Speech 4: \"Five, Four, Three, Two, One.\"",
|
"name" : "Speech 4: \"Five, Four, Three, Two, One.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 32,
|
"id" : 32,
|
||||||
"address" : 54,
|
"address" : 54,
|
||||||
"name" : "Speech 5: \"Challenge the champ!\"",
|
"name" : "Speech 5: \"Challenge the champ!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 33,
|
"id" : 33,
|
||||||
"address" : 55,
|
"address" : 55,
|
||||||
"name" : "Speech 6: \"Good. You're a champ!\"",
|
"name" : "Speech 6: \"Good. You're a champ!\""
|
||||||
"extender" : "extender_0"
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id" : 34,
|
"id" : 34,
|
||||||
"address" : 56,
|
"address" : 56,
|
||||||
"name" : "Speech 7: \"Wow.\"",
|
"name" : "Speech 7: \"Wow.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 35,
|
"id" : 35,
|
||||||
"address" : 57,
|
"address" : 57,
|
||||||
"name" : "Speech 8: \"This is a maximum score.\"",
|
"name" : "Speech 8: \"This is a maximum score.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 36,
|
"id" : 36,
|
||||||
"address" : 58,
|
"address" : 58,
|
||||||
"name" : "Speech 9: \"What a low score!\"",
|
"name" : "Speech 9: \"What a low score!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 37,
|
"id" : 37,
|
||||||
"address" : 59,
|
"address" : 59,
|
||||||
"name" : "Speech 10: \"Try harder!\"",
|
"name" : "Speech 10: \"Try harder!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 38,
|
"id" : 38,
|
||||||
"address" : 60,
|
"address" : 60,
|
||||||
"name" : "Speech 11: \"Be careful.\"",
|
"name" : "Speech 11: \"Be careful.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 39,
|
"id" : 39,
|
||||||
"address" : 61,
|
"address" : 61,
|
||||||
"name" : "Speech 12: \"The last ball.\"",
|
"name" : "Speech 12: \"The last ball.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 40,
|
"id" : 40,
|
||||||
"address" : 62,
|
"address" : 62,
|
||||||
"name" : "Speech 13: \"Be ready for the Game Time Bonus.\"",
|
"name" : "Speech 13: \"Be ready for the Game Time Bonus.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 41,
|
"id" : 41,
|
||||||
"address" : 63,
|
"address" : 63,
|
||||||
"name" : "Speech 14: \"That's naughty!\"",
|
"name" : "Speech 14: \"That's naughty!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 42,
|
"id" : 42,
|
||||||
"address" : 64,
|
"address" : 64,
|
||||||
"name" : "Speech 15: \"Another coin please.\"",
|
"name" : "Speech 15: \"Another coin please.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 43,
|
"id" : 43,
|
||||||
"address" : 65,
|
"address" : 65,
|
||||||
"name" : "Speech 16: \"Sorry. The time is over.\"",
|
"name" : "Speech 16: \"Sorry. The time is over.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 44,
|
"id" : 44,
|
||||||
"address" : 66,
|
"address" : 66,
|
||||||
"name" : "Speech 17: \"I am the champ! Challenge me!\"",
|
"name" : "Speech 17: \"I am the champ! Challenge me!\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 45,
|
"id" : 45,
|
||||||
"address" : 67,
|
"address" : 67,
|
||||||
"name" : "Speech 18: \"Time is short.\"",
|
"name" : "Speech 18: \"Time is short.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 46,
|
"id" : 46,
|
||||||
"address" : 68,
|
"address" : 68,
|
||||||
"name" : "Speech 19: \"Once again for the special.\"",
|
"name" : "Speech 19: \"Once again for the special.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 47,
|
"id" : 47,
|
||||||
"address" : 69,
|
"address" : 69,
|
||||||
"name" : "Speech 20: \"Go for the high level board.\"",
|
"name" : "Speech 20: \"Go for the high level board.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 48,
|
"id" : 48,
|
||||||
"address" : 70,
|
"address" : 70,
|
||||||
"name" : "Speech 21: \"Play gently to beat me.\"",
|
"name" : "Speech 21: \"Play gently to beat me.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 49,
|
"id" : 49,
|
||||||
"address" : 71,
|
"address" : 71,
|
||||||
"name" : "Speech 22: \"Quick! Hit the special.\"",
|
"name" : "Speech 22: \"Quick! Hit the special.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 50,
|
"id" : 50,
|
||||||
"address" : 72,
|
"address" : 72,
|
||||||
"name" : "Speech 23: \"Shoot the special.\"",
|
"name" : "Speech 23: \"Shoot the special.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 51,
|
"id" : 51,
|
||||||
"address" : 73,
|
"address" : 73,
|
||||||
"name" : "Speech 24: \"Thirty\"",
|
"name" : "Speech 24: \"Thirty\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 52,
|
"id" : 52,
|
||||||
"address" : 74,
|
"address" : 74,
|
||||||
"name" : "Speech 25: \"Red\"",
|
"name" : "Speech 25: \"Red\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 53,
|
"id" : 53,
|
||||||
"address" : 75,
|
"address" : 75,
|
||||||
"name" : "Speech 27: \"Yellow\"",
|
"name" : "Speech 27: \"Yellow\""
|
||||||
"extender" : "extender_0"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : 54,
|
"id" : 54,
|
||||||
"address" : 76,
|
"address" : 76,
|
||||||
"name" : "Speech 28: \"Go for the Special.\"",
|
"name" : "Speech 28: \"Go for the Special.\""
|
||||||
"extender" : "extender_0"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,10 +59,9 @@ std::map<std::string, std::shared_ptr<ItemType>> get_items(const std::string &co
|
|||||||
nlohmann::json config_json;
|
nlohmann::json config_json;
|
||||||
config_stream >> config_json;
|
config_stream >> config_json;
|
||||||
|
|
||||||
FactoryType factory{config_json, std::static_pointer_cast<ControllerType>(pin_controller)};
|
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<ItemType>> map;
|
std::map<std::string, std::shared_ptr<ItemType>> map;
|
||||||
try{
|
try{
|
||||||
|
FactoryType factory{config_json, std::static_pointer_cast<ControllerType>(pin_controller)};
|
||||||
map = factory.getItemMap();
|
map = factory.getItemMap();
|
||||||
}
|
}
|
||||||
catch(json::exception & e)
|
catch(json::exception & e)
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ void OutputDriver::shut_down_driver() const
|
|||||||
this->deactivate_all_flipper_relays();
|
this->deactivate_all_flipper_relays();
|
||||||
this->deactivate_all_lamps();
|
this->deactivate_all_lamps();
|
||||||
this->deactivate_displays();
|
this->deactivate_displays();
|
||||||
|
|
||||||
|
CLOG(INFO, OUTPUT_LOGGER) << "Deactivated all output items.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,18 +71,28 @@ void SoundBoardPinController::write_pin(const uint8_t &pin, const bool &value) c
|
|||||||
{
|
{
|
||||||
PinController::write_pin(pin, value);
|
PinController::write_pin(pin, value);
|
||||||
PinController::write_pin(this->fire_address, true);
|
PinController::write_pin(this->fire_address, true);
|
||||||
|
|
||||||
PinController::write_pin(this->fire_address, false);
|
PinController::write_pin(this->fire_address, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardPinController::set_address_pins(std::vector<uint8_t> address_pins)
|
void SoundBoardPinController::set_address_pins(std::vector<uint8_t> address_pins)
|
||||||
{
|
{
|
||||||
this->address_pins = address_pins;
|
this->address_pins = address_pins;
|
||||||
|
|
||||||
|
//print string in a nice manner
|
||||||
|
std::stringstream ss;
|
||||||
|
for (auto & p : address_pins)
|
||||||
|
{
|
||||||
|
ss << int{p} << ", ";
|
||||||
|
}
|
||||||
|
ss << std::string(2, 0x08);
|
||||||
|
|
||||||
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Pin addresses for sounds set to: [" << ss.str() << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardPinController::set_fire_address(const uint8_t &fire_address)
|
void SoundBoardPinController::set_fire_address(const uint8_t &fire_address)
|
||||||
{
|
{
|
||||||
this->fire_address = fire_address;
|
this->fire_address = fire_address;
|
||||||
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Fire-pin address for sounds set to: " << int{fire_address};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ std::map<std::string, std::shared_ptr<items::Flipper>> FlipperFactory::getItemMa
|
|||||||
auto extender = flipper.at(config_path::item_extender).get<std::string>();
|
auto extender = flipper.at(config_path::item_extender).get<std::string>();
|
||||||
auto pin_base = this->get_extender_pin_base(extender);
|
auto pin_base = this->get_extender_pin_base(extender);
|
||||||
|
|
||||||
auto flipper_item = std::make_shared<items::detail::Flipper>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address, pin_base, name);
|
auto flipper_item = std::make_shared<items::detail::Flipper>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address + pin_base, name);
|
||||||
flipper_map.emplace(name, flipper_item);
|
flipper_map.emplace(name, flipper_item);
|
||||||
}
|
}
|
||||||
return flipper_map;
|
return flipper_map;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ std::map<std::string, std::shared_ptr<items::Lamp>> LampFactory::getItemMap()
|
|||||||
auto address = lamp.at(config_path::item_address).get<uint8_t >();
|
auto address = lamp.at(config_path::item_address).get<uint8_t >();
|
||||||
auto extender = lamp.at(config_path::item_extender).get<std::string>();
|
auto extender = lamp.at(config_path::item_extender).get<std::string>();
|
||||||
auto pin_base = this->get_extender_pin_base(extender);
|
auto pin_base = this->get_extender_pin_base(extender);
|
||||||
auto lamp_item = std::make_shared<items::detail::Lamp>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address, pin_base, name);
|
|
||||||
|
auto lamp_item = std::make_shared<items::detail::Lamp>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address + pin_base, name);
|
||||||
lamp_map.emplace(name, lamp_item);
|
lamp_map.emplace(name, lamp_item);
|
||||||
}
|
}
|
||||||
return lamp_map;
|
return lamp_map;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ std::map<std::string, std::shared_ptr<items::Solenoid>> SolenoidFactory::getItem
|
|||||||
deactivation_time_chrono = std::chrono::milliseconds{solenoid.at(config_path::deactivation_time).get<uint8_t>()};
|
deactivation_time_chrono = std::chrono::milliseconds{solenoid.at(config_path::deactivation_time).get<uint8_t>()};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto solenoid_item = std::make_shared<items::detail::Solenoid>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address, pin_base, name, deactivation_time_chrono);
|
auto solenoid_item = std::make_shared<items::detail::Solenoid>(std::static_pointer_cast<DriverBoardPinController>(this->pin_controller), address + pin_base, name, deactivation_time_chrono);
|
||||||
solenoid_map.emplace(name, solenoid_item);
|
solenoid_map.emplace(name, solenoid_item);
|
||||||
}
|
}
|
||||||
return solenoid_map;
|
return solenoid_map;
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ std::map<std::string, std::shared_ptr<items::Sound>> SoundFactory::getItemMap()
|
|||||||
{
|
{
|
||||||
auto name = sound.at(config_path::item_name).get<std::string>();
|
auto name = sound.at(config_path::item_name).get<std::string>();
|
||||||
auto address = sound.at(config_path::item_address).get<uint8_t >();
|
auto address = sound.at(config_path::item_address).get<uint8_t >();
|
||||||
auto extender = sound.at(config_path::item_extender).get<std::string>();
|
|
||||||
auto pin_base = this->get_extender_pin_base(extender);
|
|
||||||
auto id = sound.at(config_path::item_identifier).get<uint>();
|
auto id = sound.at(config_path::item_identifier).get<uint>();
|
||||||
|
|
||||||
std::chrono::milliseconds deactivation_time_chrono{this->deactivation_time};
|
std::chrono::milliseconds deactivation_time_chrono{this->deactivation_time};
|
||||||
@@ -42,7 +40,7 @@ std::map<std::string, std::shared_ptr<items::Sound>> SoundFactory::getItemMap()
|
|||||||
{
|
{
|
||||||
deactivation_time_chrono = std::chrono::milliseconds{sound.at(config_path::deactivation_time).get<uint8_t>()};
|
deactivation_time_chrono = std::chrono::milliseconds{sound.at(config_path::deactivation_time).get<uint8_t>()};
|
||||||
}
|
}
|
||||||
auto sound_item = std::make_shared<items::detail::Sound>(std::static_pointer_cast<SoundBoardPinController>(this->pin_controller), address, pin_base, name, deactivation_time_chrono, id);
|
auto sound_item = std::make_shared<items::detail::Sound>(std::static_pointer_cast<SoundBoardPinController>(this->pin_controller), address, name, deactivation_time_chrono, id);
|
||||||
|
|
||||||
sound_map.emplace(name, sound_item);
|
sound_map.emplace(name, sound_item);
|
||||||
}
|
}
|
||||||
@@ -67,9 +65,21 @@ void SoundFactory::set_address_pins()
|
|||||||
|
|
||||||
std::vector<uint8_t> pins;
|
std::vector<uint8_t> pins;
|
||||||
|
|
||||||
for (auto & pin : address_pins)
|
for (auto & pin_json : address_pins)
|
||||||
{
|
{
|
||||||
pins.push_back(pin.get<uint8_t>());
|
pins.push_back(0);
|
||||||
|
}
|
||||||
|
for (auto & pin_json : address_pins)
|
||||||
|
{
|
||||||
|
uint8_t pin = pin_json.at(config_path::item_address).get<uint8_t>();
|
||||||
|
if (pin_json.find(config_path::item_extender) != pin_json.end())
|
||||||
|
{
|
||||||
|
auto extender_name = pin_json.at(config_path::item_extender).get<std::string>();
|
||||||
|
pin += this->get_extender_pin_base(extender_name);
|
||||||
|
}
|
||||||
|
uint8_t id = pin_json.at(config_path::item_identifier).get<uint8_t>();
|
||||||
|
|
||||||
|
pins[id] = pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::dynamic_pointer_cast<detail::SoundBoardPinController>(this->pin_controller)->set_address_pins(pins);
|
std::dynamic_pointer_cast<detail::SoundBoardPinController>(this->pin_controller)->set_address_pins(pins);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
using namespace flippR_driver::output;
|
using namespace flippR_driver::output;
|
||||||
|
|
||||||
items::detail::DriverBoardItem::DriverBoardItem(std::shared_ptr<PinController> pin_controller, const uint8_t & address, const uint8_t & pin_base) :
|
items::detail::DriverBoardItem::DriverBoardItem(std::shared_ptr<PinController> pin_controller, const uint8_t & address) :
|
||||||
address(pin_base + address)
|
address(address)
|
||||||
{
|
{
|
||||||
pin_controller->initialize_output_pin(this->address);
|
pin_controller->initialize_output_pin(this->address);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace detail
|
|||||||
class DriverBoardItem : public output::items::DriverBoardItem
|
class DriverBoardItem : public output::items::DriverBoardItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DriverBoardItem(std::shared_ptr<PinController> pin_controller, const uint8_t & address, const uint8_t & pin_base);
|
DriverBoardItem(std::shared_ptr<PinController> pin_controller, const uint8_t & address);
|
||||||
|
|
||||||
~DriverBoardItem() override = default;
|
~DriverBoardItem() override = default;
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ namespace items
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Flipper::Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name) :
|
Flipper::Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name) :
|
||||||
Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller))
|
Item(std::move(name)), DriverBoardItem(pin_controller, address), pin_controller(std::move(pin_controller))
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created flipper \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created flipper \"" << name << "\" with address " << int(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
Flipper::~Flipper()
|
Flipper::~Flipper()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace detail
|
|||||||
class Flipper : public detail::Item, public items::Flipper, public detail::DriverBoardItem
|
class Flipper : public detail::Item, public items::Flipper, public detail::DriverBoardItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name);
|
Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name);
|
||||||
~Flipper() override;
|
~Flipper() override;
|
||||||
|
|
||||||
void activate() override;
|
void activate() override;
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ namespace items
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name) :
|
Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name) :
|
||||||
detail::Item(std::move(name)),
|
detail::Item(std::move(name)),
|
||||||
DriverBoardItem(pin_controller, address, pin_base),
|
DriverBoardItem(pin_controller, address),
|
||||||
pin_controller(std::move(pin_controller)),
|
pin_controller(std::move(pin_controller)),
|
||||||
activated(false),
|
activated(false),
|
||||||
activation_time(10)
|
activation_time(10)
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created lamp \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created lamp \"" << name << "\" with address " << int(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lamp::activate()
|
void Lamp::activate()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace detail
|
|||||||
class Lamp : public detail::DriverBoardItem, public detail::Item, public items::Lamp
|
class Lamp : public detail::DriverBoardItem, public detail::Item, public items::Lamp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name);
|
Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name);
|
||||||
~Lamp() override = default;
|
~Lamp() override = default;
|
||||||
|
|
||||||
void activate() override;
|
void activate() override;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace items
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time)
|
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time)
|
||||||
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(pin_controller), deactivation_time(deactivation_time)
|
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address), pin_controller(pin_controller), deactivation_time(deactivation_time)
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created solenoid " << name << " with address " << int{address} << " and deactivation-time: " << deactivation_time.count();
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created solenoid " << name << " with address " << int{address} << " and deactivation-time: " << deactivation_time.count();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace detail
|
|||||||
class Solenoid : public DriverBoardItem, public detail::Item, public items::Solenoid
|
class Solenoid : public DriverBoardItem, public detail::Item, public items::Solenoid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time);
|
Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time);
|
||||||
~Solenoid() override = default;
|
~Solenoid() override = default;
|
||||||
|
|
||||||
void trigger() override;
|
void trigger() override;
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ namespace items
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id)
|
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id)
|
||||||
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id)
|
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id)
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address) << ". Deactivation time is: " << deactivation_time.count();
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with address " << int(address) << ". Deactivation time is: " << deactivation_time.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::play()
|
void Sound::play()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
u_int id;
|
u_int id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id);
|
Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id);
|
||||||
~Sound() override = default;
|
~Sound() override = default;
|
||||||
|
|
||||||
void play() override;
|
void play() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user