@@ -21,12 +21,12 @@ Application::Application() {
2121
2222 sim.vis .create ();
2323
24- user_interface.addElement <UiWindow>( " MainMenu " , [this ](UiWindow* window ){
24+ user_interface.m_main_menu = [this ](){
2525 if (ImGui::BeginMainMenuBar ()) {
2626 if (ImGui::BeginMenu (" File" )) {
27- if (ImGui::MenuItem (" Preferences" )) {
28- user_interface.ui_elements [" Preferences" ]->enable ();
29- }
27+ // if (ImGui::MenuItem("Preferences")) {
28+ // user_interface.ui_elements["Preferences"]->enable();
29+ // }
3030 if (ImGui::MenuItem (" Quit" )) {
3131 Kernel::quit_requested = true ;
3232 active = false ;
@@ -55,7 +55,7 @@ Application::Application() {
5555 }
5656 ImGui::EndMainMenuBar ();
5757 }
58- }) ;
58+ };
5959
6060 user_interface.addElement <SerialMonitor>(" Serial Monitor(0)" , serial_stream_0);
6161 user_interface.addElement <SerialMonitor>(" Serial Monitor(1)" , serial_stream_1);
@@ -221,57 +221,52 @@ Application::Application() {
221221 ImGui::InputText (" Pin regex" , export_regex, sizeof (export_regex));
222222
223223 if (ImGuiFileDialog::Instance ()->Display (" PulseExportDlgKey" , ImGuiWindowFlags_NoDocking)) {
224- try {
225- if (ImGuiFileDialog::Instance ()->IsOk ()) {
226- std::string image_filename = ImGuiFileDialog::Instance ()->GetFilePathName ();
224+ try {
225+ if (ImGuiFileDialog::Instance ()->IsOk ()) {
226+ std::string image_filename = ImGuiFileDialog::Instance ()->GetFilePathName ();
227227
228- using namespace vcd ;
228+ using namespace vcd ;
229229
230- HeadPtr head = makeVCDHeader (static_cast <TimeScale>(50 ), TimeScaleUnit::ns, utils::now ());
231- VCDWriter writer{image_filename, head};
230+ HeadPtr head = makeVCDHeader (static_cast <TimeScale>(50 ), TimeScaleUnit::ns, utils::now ());
231+ VCDWriter writer {image_filename, head};
232232
233- if (export_single_pin) {
234- std::string pin_name (active_label);
235- auto scope = pin_name.substr (0 , pin_name.find_first_of (' _' ));
236- auto var = writer.register_var (scope, pin_name, VariableType::wire, 1 );
233+ if (export_single_pin) {
234+ std::string pin_name (active_label);
235+ auto scope = pin_name.substr (0 , pin_name.find_first_of (' _' ));
236+ auto var = writer.register_var (scope, pin_name, VariableType::wire, 1 );
237237
238- if (Gpio::pin_map[monitor_pin].event_log .size () && pin_array[monitor_pin].is_digital ) {
239- for (const auto &value : Gpio::pin_map[monitor_pin].event_log ) {
240- writer.change (var, value.timestamp / 50 , utils::format (" %u" , value.value ));
238+ if (Gpio::pin_map[monitor_pin].event_log .size () && pin_array[monitor_pin].is_digital ) {
239+ for (const auto & value : Gpio::pin_map[monitor_pin].event_log ) {
240+ writer.change (var, value.timestamp / 50 , utils::format (" %u" , value.value ));
241+ }
242+ }
243+ } else {
244+ std::map<size_t , VarPtr> pin_to_var_map;
245+ std::regex expression (export_regex);
246+
247+ for (auto pin : pin_array) {
248+ std::string pin_name (pin.name );
249+ bool regex_match = strlen (export_regex) == 0 || std::regex_search (pin_name, expression);
250+ auto scope = pin_name.substr (0 , pin_name.find_first_of (' _' ));
251+ if (pin.is_digital && regex_match) pin_to_var_map[pin.pin ] = writer.register_var (scope, pin_name, VariableType::wire, 1 );
241252 }
242- }
243- }
244- else {
245- std::map<size_t , VarPtr> pin_to_var_map;
246- std::regex expression (export_regex);
247-
248- for (auto pin : pin_array) {
249- std::string pin_name (pin.name );
250- bool regex_match = strlen (export_regex) == 0 || std::regex_search (pin_name, expression);
251- auto scope = pin_name.substr (0 , pin_name.find_first_of (' _' ));
252- if (pin.is_digital && regex_match)
253- pin_to_var_map[pin.pin ] = writer.register_var (scope, pin_name, VariableType::wire, 1 );
254- }
255253
256- std::multimap<uint64_t , std::pair<pin_t , uint16_t > > timestamp_pin_change_map;
254+ std::multimap<uint64_t , std::pair<pin_t , uint16_t >> timestamp_pin_change_map;
257255
258- for (auto pin : pin_array) {
259- if (pin.is_digital && pin_to_var_map.find (pin.pin ) != pin_to_var_map.end ())
260- for (const auto &data : Gpio::pin_map[pin.pin ].event_log )
261- {
262- timestamp_pin_change_map.emplace (std::make_pair (data.timestamp , std::make_pair (pin.pin , data.value )));
263- }
264- }
256+ for (auto pin : pin_array) {
257+ if (pin.is_digital && pin_to_var_map.find (pin.pin ) != pin_to_var_map.end ())
258+ for (const auto & data : Gpio::pin_map[pin.pin ].event_log ) {
259+ timestamp_pin_change_map.emplace (std::make_pair (data.timestamp , std::make_pair (pin.pin , data.value )));
260+ }
261+ }
265262
266- auto timestamp_offset = timestamp_pin_change_map.begin ()->first ;
267- for (const auto ×tamp : timestamp_pin_change_map) {
268- writer.change (pin_to_var_map[timestamp.second .first ], (timestamp.first - timestamp_offset) / 50 , utils::format (" %u" , timestamp.second .second ));
263+ auto timestamp_offset = timestamp_pin_change_map.begin ()->first ;
264+ for (const auto & timestamp : timestamp_pin_change_map) {
265+ writer.change (pin_to_var_map[timestamp.second .first ], (timestamp.first - timestamp_offset) / 50 , utils::format (" %u" , timestamp.second .second ));
266+ }
269267 }
270268 }
271- }
272- }
273- catch (const std::exception& e)
274- {
269+ } catch (const std::exception& e) {
275270 auto test = e.what ();
276271 }
277272 ImGuiFileDialog::Instance ()->Close ();
0 commit comments