diff --git a/Changelog b/Changelog index 2f4d81b..f0b0635 100644 --- a/Changelog +++ b/Changelog @@ -15,6 +15,14 @@ Licence GPL v2 (see ) LAST CHANGES +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +2026/02/01 ericb + +Correction de la modulation M-ASK : maintenant, les amplitudes respectent la règle Ak = 2k-M-1 +Suppression de la double initiaisation de la SDL. +Ajout de la fenêtre modale qui servira de modèle pour la documentation du cours (consultable en runtime) + + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2026/01/25 ericb diff --git a/Makefile b/Makefile index b1c3b47..331aa6b 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,7 @@ SOURCES = \ ${SOURCES_DIR}/modulations.cxx \ ${SOURCES_DIR}/imgui_utils.cxx \ ${SOURCES_DIR}/application.cxx \ + ${SOURCES_DIR}/cours_popup.cxx \ ${SOURCES_DIR}/engine.cxx \ ${SOURCES_DIR}/main.cxx diff --git a/inc/cours_popup.h b/inc/cours_popup.h new file mode 100644 index 0000000..510370a --- /dev/null +++ b/inc/cours_popup.h @@ -0,0 +1,7 @@ +#ifndef COURS_POPUP_H +#define COURS_POPUP_H +#include "modulations.h" + +void afficher_cours_modal_popup(DigitalModulationType); + +#endif diff --git a/src/cours_popup.cxx b/src/cours_popup.cxx new file mode 100644 index 0000000..93ef852 --- /dev/null +++ b/src/cours_popup.cxx @@ -0,0 +1,70 @@ +#include +#include "cours_popup.h" + +#define CLOSE_WINDOW_WIDTH 180 +#define CLOSE_WINDOW_HEIGHT 50 + +void afficher_cours_modal_popup(DigitalModulationType dType) +{ + /// Dessin du bouton "Rappels de cours " + + // Centrage de la fenêtre modale + ImVec2 center = ImGui::GetMainViewport()->GetCenter(); + ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + ImVec2 displaySize = ImGui::GetIO().DisplaySize; + ImGui::SetNextWindowSize(ImVec2(displaySize.x * 0.8f,displaySize.y * 0.8f), ImGuiCond_Always); + + ImGui::SetNextItemWidth(CLOSE_WINDOW_WIDTH); + float largeur_fenetre = ImGui::GetContentRegionAvail().x; + + ImGui::NewLine(); + ImGui::Dummy(ImVec2((largeur_fenetre - CLOSE_WINDOW_WIDTH) * 0.5f, 0.0)); + ImGui::SameLine(); + + if (ImGui::Button("Rappels de cours")) + ImGui::OpenPopup("Rappels de cours"); + + if (ImGui::BeginPopupModal("Rappels de cours", NULL, ImGuiWindowFlags_AlwaysAutoResize)) + { + ImGui::BeginChild("Scroll",ImVec2(displaySize.x * 0.8, displaySize.y * 0.65),true, ImGuiWindowFlags_AlwaysVerticalScrollbar); + + switch (dType) + { + case MOD_OOK_TYPE: +// ImGui::TextWraped(OOK_COURSE_DOC); +// break; + case MOD_ASK_TYPE: + case MOD_MASK_TYPE: + case MOD_FSK_TYPE: + case MOD_MFSK_TYPE: + case MOD_BPSK_TYPE: + case MOD_DPSK_TYPE: + case MOD_4_QAM_TYPE: + case MOD_16_QAM_TYPE: + break; + + default: + break; + } + + ImGui::TextWrapped("Je rajoute plein de mot afin que le texte soit tres long genre vraiment tres long BLABLLALBLALBALBLABLBLALABLBALALBLABLLBALBALBALBALBLAABLLALABLBAL "); + ImGui::Separator(); + + for (int i = 0; i < 50; i++) + { + ImGui::Text("Y'a vraiment plein d'information dans cette phrase dis donc (c'est faux) Ligne %d", i + 1); + } + + ImGui::EndChild(); + + largeur_fenetre = ImGui::GetContentRegionAvail().x; + ImGui::NewLine(); + + ImGui::Dummy(ImVec2((largeur_fenetre - CLOSE_WINDOW_WIDTH) * 0.5f, 0.0)); + ImGui::SameLine(); + + if (ImGui::Button("Fermer la fenêtre", ImVec2(CLOSE_WINDOW_WIDTH, 0))) + ImGui::CloseCurrentPopup(); + ImGui::EndPopup(); + } +} diff --git a/src/main.cxx b/src/main.cxx index f0a51dd..3878164 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -15,7 +15,6 @@ #include "modulations.h" #include "application.h" - static void showApplicationQuitMenu() { if (ImGui::BeginMenu(APPLICATION_MENU_HEAD)) @@ -37,13 +36,6 @@ int main(void) Application app; Application * p_app = &app; - // --------------------- SDL INIT --------------------- - if (!SDL_Init(SDL_INIT_VIDEO)) - { - fprintf(stdout, "SDL init error: %s\n", SDL_GetError()); - return -1; - } - Engine engine; // -----------------IMGUI INIT--------------------------- diff --git a/src/modulations.cxx b/src/modulations.cxx index 2eaf614..63b30ea 100644 --- a/src/modulations.cxx +++ b/src/modulations.cxx @@ -15,6 +15,7 @@ #include "imgui_utils.h" #include "vtoggle_button.h" #include "gl_helpers.h" +#include "cours_popup.h" #ifdef M_PI #undef M_PI @@ -111,6 +112,7 @@ short int DigitalModulation::AmplitudeDigitalModulation(float * carrier_freq, ); float amplitude = 0.0f; + int somme = 0; switch (amplitude_modulation_t) { @@ -123,11 +125,34 @@ short int DigitalModulation::AmplitudeDigitalModulation(float * carrier_freq, break; case MOD_MASK_TYPE: + if ((bit_traite % 2) == 0) // bit pair => bits 0, 2, 4 ou 6 - amplitude = base_amp * (0.25 + 0.5 * am_bits[bit_traite] + 0.25 * am_bits[bit_traite+1]); - else // bit impair => bits 1, 3, 5 ou 7 - amplitude = base_amp * (0.25 + 0.5 * am_bits[bit_traite-1] + 0.25 * am_bits[bit_traite]); - break; + somme = 2*am_bits[bit_traite]+am_bits[bit_traite+1]; + else + somme = 2*am_bits[bit_traite-1]+am_bits[bit_traite]; + + switch(somme) + { + case 0: + amplitude = -base_amp * 0.33f; + break; + + case 1: + amplitude = - base_amp; + break; + + case 2: + amplitude = base_amp * 0.33f; + break; + + case 3: + amplitude = base_amp; + break; + + default: + break; + } + break; default: break; @@ -177,57 +202,60 @@ short int DigitalModulation::AmplitudeDigitalModulation(float * carrier_freq, ImGui::SameLine(); ImGui::BeginChild("Options", ImVec2(CHILD2_WIDTH - 8.0f /* minus the border */, 0), true); - ImGui::Text("Type de modulation"); - ImGui::Separator(); + ImGui::Text("Type de modulation"); + ImGui::Separator(); - ImGui::RadioButton("OOK " , (int*)&litude_modulation_t, MOD_OOK_TYPE); - ImGui::RadioButton("ASK " , (int*)&litude_modulation_t, MOD_ASK_TYPE); - ImGui::RadioButton("4-ASK ", (int*)&litude_modulation_t, MOD_MASK_TYPE); + ImGui::RadioButton("OOK " , (int*)&litude_modulation_t, MOD_OOK_TYPE); + ImGui::RadioButton("ASK " , (int*)&litude_modulation_t, MOD_ASK_TYPE); + ImGui::RadioButton("4-ASK ", (int*)&litude_modulation_t, MOD_MASK_TYPE); - // --- AJOUT TÉMOIN --- - ImGui::Spacing(); - ImGui::Separator(); - ImGui::Text("Principe :"); - ImGui::Spacing(); + // --- AJOUT TÉMOIN --- + ImGui::Spacing(); + ImGui::Separator(); + ImGui::Text("Principe :"); + ImGui::Spacing(); - ImVec2 ind_size(ImGui::GetContentRegionAvail().x - 10, 50); - ImU32 col = IM_COL32(0, 120, 255, 255); // Même bleu que le signal + ImVec2 ind_size(ImGui::GetContentRegionAvail().x - 10, 50); + ImU32 col = IM_COL32(0, 120, 255, 255); // Même bleu que le signal - switch(amplitude_modulation_t) - { - case MOD_OOK_TYPE: - case MOD_ASK_TYPE: - ImGui::Text("1 bit par symbole"); - ImGui::NewLine(); - DrawIndicator("Le bit vaut 1 :", &c_freq, &litude_modulation_t, &samples_per_bit, 1.0f, 0.0f, col, ind_size); + switch(amplitude_modulation_t) + { + case MOD_OOK_TYPE: + case MOD_ASK_TYPE: + ImGui::Text("1 bit par symbole"); + ImGui::NewLine(); + DrawIndicator("Le bit vaut 1 :", &c_freq, &litude_modulation_t, &samples_per_bit, 1.0f, 0.0f, col, ind_size); - ImGui::NewLine(); - DrawIndicator ("Le bit vaut 0 :", - &c_freq, &litude_modulation_t, - &samples_per_bit, ((MOD_ASK_TYPE == amplitude_modulation_t) ? 0.4f : 0.0f), - 0.0f, - col, - ind_size - ); - break; + ImGui::NewLine(); + DrawIndicator ("Le bit vaut 0 :", + &c_freq, &litude_modulation_t, + &samples_per_bit, ((MOD_ASK_TYPE == amplitude_modulation_t) ? 0.4f : 0.0f), + 0.0f, + col, + ind_size + ); + break; - case MOD_MASK_TYPE: - ImGui::Text("2 bits par symbole"); - ImGui::NewLine(); - DrawIndicator("Le symbole vaut 11 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 1.0f, 0.0f, col, ind_size); - ImGui::NewLine(); - DrawIndicator("Le symbole vaut 10 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 0.75f, 0.0f, col, ind_size); - ImGui::NewLine(); - DrawIndicator("Le symbole vaut 01 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 0.4f, 0.0f, col, ind_size); - ImGui::NewLine(); - DrawIndicator("Le symbole vaut 00 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 0.15f, 0.0f, col, ind_size); - break; + case MOD_MASK_TYPE: + ImGui::Text("2 bits par symbole"); + ImGui::NewLine(); + DrawIndicator("Le symbole vaut 11 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 1.0f, 0.0f, col, ind_size); + ImGui::NewLine(); + DrawIndicator("Le symbole vaut 10 : ", &c_freq, &litude_modulation_t, &samples_per_bit, 0.33f, 0.0f, col, ind_size); + ImGui::NewLine(); + DrawIndicator("Le symbole vaut 01 : ", &c_freq, &litude_modulation_t, &samples_per_bit, -1.0f, 0.0f, col, ind_size); + ImGui::NewLine(); + DrawIndicator("Le symbole vaut 00 : ", &c_freq, &litude_modulation_t, &samples_per_bit, -0.33f, 0.0f, col, ind_size); + break; - default: - break; - } - // ------- FIN AJOUT TEMOIN ------------- + default: + break; + } + // ------- FIN AJOUT TEMOIN ------------- + + /// Dessin du bouton "Rappels de cours " + afficher_cours_modal_popup(amplitude_modulation_t); ImGui::EndChild();