ajout oscillo

This commit is contained in:
thomas committed 2026-09-05 21:52:15 +02:00
1 parent 5cf2212fc0
commit f01d3213c0
18 files changed
+741 -12

No files matched your search

+284 -8
View File
@@ -71,7 +71,7 @@
{
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel1",
"Y": 93,
"Y": 134,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -93,7 +93,7 @@
{
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel2",
"Y": 281,
"Y": 322,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -116,7 +116,7 @@
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel3",
"X": 380,
"Y": 281,
"Y": 322,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -138,7 +138,7 @@
{
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel4",
"Y": 187,
"Y": 228,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -161,7 +161,7 @@
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel5",
"X": 380,
"Y": 187,
"Y": 228,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -184,7 +184,7 @@
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel6",
"X": 380,
"Y": 93,
"Y": 134,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
@@ -203,16 +203,67 @@
"TextRotation": "0",
"Preset": "glass_theme\\presets\\button\\regular\\height_50\\large_rounded_normal.json"
},
{
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel7",
"X": 190,
"Y": 396,
"Width": 420,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_pressed.png",
"Released": "__generated\\glass_theme_images_widgets_button_regular_height_50_large_rounded_normal.png",
"TextId": "OSCILLO",
"ReleasedColor": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"PressedColor": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"TextRotation": "0",
"Preset": "glass_theme\\presets\\button\\regular\\height_50\\large_rounded_normal.json"
},
{
"Type": "ToggleButton",
"Name": "toggleButton1",
"X": 118,
"Y": 22,
"X": 135,
"Y": 18,
"Width": 170,
"Height": 60,
"Pressed": "__generated\\glass_theme_images_widgets_togglebutton_large_rounded_text_on_active.png",
"Released": "__generated\\glass_theme_images_widgets_togglebutton_large_rounded_text_off_normal.png",
"Preset": "glass_theme\\presets\\togglebutton\\large\\rounded_active_text.json"
},
{
"Type": "Slider",
"Name": "slider1",
"X": 329,
"Y": 22,
"Width": 456,
"Height": 52,
"IsHorizontalSlider": true,
"BackgroundUnselected": "__generated\\glass_theme_images_widgets_slider_horizontal_thick_track_large.png",
"BackgroundSelected": "__generated\\glass_theme_images_widgets_slider_horizontal_thick_filler_large.png",
"Indicator": "__generated\\glass_theme_images_widgets_slider_horizontal_thick_rounded_dark.png",
"BackgroundX": 28,
"BackgroundY": 21,
"IndicatorMax": 400,
"ValueMax": 100,
"Preset": "glass_theme\\presets\\slider\\horizontal\\thick\\large_rounded_dark.json"
},
{
"Type": "ScalableImage",
"Name": "scalableImage1",
"X": 15,
"Y": 4,
"Width": 105,
"Height": 95,
"Filename": "__generated\\icon_theme_images_hardware_headset_50_50_FFFFFF.svg.png",
"Alpha": 149,
"ScalingAlgorithm": "Bilinear Interpolation"
}
],
"Interactions": [
@@ -298,6 +349,39 @@
"ScreenTransitionType": "ScreenTransitionNone",
"ActionComponent": "Octaver"
}
},
{
"InteractionName": "Interaction8",
"Trigger": {
"Type": "TriggerSliderValueChanged",
"TriggerComponent": "slider1"
},
"Action": {
"Type": "ActionCustom",
"FunctionName": "slider1Changed"
}
},
{
"InteractionName": "Interaction9",
"Trigger": {
"Type": "TriggerSliderValueConfirmed",
"TriggerComponent": "slider1"
},
"Action": {
"Type": "ActionNone"
}
},
{
"InteractionName": "Interaction10",
"Trigger": {
"Type": "TriggerClicked",
"TriggerComponent": "buttonWithLabel7"
},
"Action": {
"Type": "ActionGotoScreen",
"ScreenTransitionType": "ScreenTransitionNone",
"ActionComponent": "Oscillo"
}
}
]
},
@@ -2018,6 +2102,198 @@
}
}
]
},
{
"Name": "Oscillo",
"CanvasBufferSize": 12000,
"Components": [
{
"Type": "Image",
"Name": "image1",
"Y": -1,
"Width": 800,
"Height": 483,
"RelativeFilename": "fondHorlogerie1.png"
},
{
"Type": "Box",
"Name": "box1",
"Width": 800,
"Height": 480,
"Color": {
"Red": 35,
"Green": 24,
"Blue": 15
},
"Alpha": 240
},
{
"Type": "TextArea",
"Name": "textArea1",
"X": 314,
"Y": 26,
"Width": 173,
"Height": 42,
"TextId": "OSCILLO",
"TextRotation": "0",
"Color": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"AutoSize": true
},
{
"Type": "ToggleButton",
"Name": "toggleButton1",
"X": 576,
"Y": 20,
"Width": 170,
"Height": 60,
"Pressed": "__generated\\glass_theme_images_widgets_togglebutton_large_round_text_on_active.png",
"Released": "__generated\\glass_theme_images_widgets_togglebutton_large_round_text_off_normal.png",
"Preset": "glass_theme\\presets\\togglebutton\\large\\round_active_text.json"
},
{
"Type": "ButtonWithLabel",
"Name": "buttonWithLabel1",
"Width": 225,
"Height": 94,
"Pressed": "__generated\\glass_theme_images_widgets_button_regular_height_50_small_rounded_pressed.png",
"Released": "__generated\\glass_theme_images_widgets_button_regular_height_50_small_rounded_normal.png",
"TextId": "BACK",
"ReleasedColor": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"PressedColor": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"TextRotation": "0",
"Preset": "glass_theme\\presets\\button\\regular\\height_50\\small_rounded_normal.json"
},
{
"Type": "StaticGraph",
"Name": "graph1",
"Y": 94,
"Width": 800,
"Height": 386,
"DataSeed": 676876642,
"NumberOfValues": 1024,
"MaxX": 24000.0,
"PrecisionX": "1",
"MaxY": 100.0,
"PrecisionY": "1",
"XAxisScale": 1.0,
"InsertRandomValues": true,
"LabelSizeBottom": 63,
"LabelSizeLeft": 16,
"LabelSizeRight": 16,
"PaddingBottom": 17,
"GraphDrawers": [
{
"Type": "LineDrawer",
"LineWidth": 2,
"FileNameImage": "",
"Color": {
"Red": 20,
"Green": 151,
"Blue": 197
}
}
],
"XAxisGrid": {
"Type": "GraphGrid",
"Color": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"Interval": 2400.0,
"LineWidth": 1
},
"YAxisGrid": {
"Type": "GraphGrid",
"Color": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"Interval": 25.0,
"LineWidth": 1
},
"XAxisLabel": {
"Type": "GraphLabel",
"Interval": 2400.0,
"DecimalSeparator": "Point",
"TextColor": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"TextId": "__SingleUse_2C9Q",
"TextRotation": "270",
"Position": "Bottom"
}
},
{
"Type": "Image",
"Name": "image2",
"X": 535,
"Y": 74,
"Width": 264,
"Height": 80,
"RelativeFilename": "__generated\\glass_theme_images_widgets_button_regular_height_36_medium_round_action.png"
},
{
"Type": "TextArea",
"Name": "textArea2",
"X": 582,
"Y": 104,
"Width": 181,
"Height": 23,
"TextId": "textAreaMax",
"TextRotation": "0",
"Color": {
"Red": 230,
"Green": 214,
"Blue": 170
},
"Wildcard1": {
"TextId": "__SingleUse_U5V0",
"UseBuffer": true,
"BufferSize": 10
}
}
],
"Interactions": [
{
"InteractionName": "Interaction1",
"Trigger": {
"Type": "TriggerClicked",
"TriggerComponent": "buttonWithLabel1"
},
"Action": {
"Type": "ActionGotoScreen",
"ScreenTransitionType": "ScreenTransitionNone",
"ActionComponent": "Overview"
}
},
{
"InteractionName": "Interaction2",
"Trigger": {
"Type": "TriggerClicked",
"TriggerComponent": "toggleButton1"
},
"Action": {
"Type": "ActionCustom",
"FunctionName": "toggleClicked"
}
}
]
}
],
"CustomContainerDefinitions": [],
Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

+15 -2
View File
@@ -14,6 +14,9 @@
<Text Id="OCTAVER" Alignment="Center" TypographyId="Large">
<Translation Language="GB">OCTAVER</Translation>
</Text>
<Text Id="OSCILLO" Alignment="Center" TypographyId="Large">
<Translation Language="GB">OSCILLO</Translation>
</Text>
<Text Id="OVERDRIVE" Alignment="Center" TypographyId="Large">
<Translation Language="GB" Alignment="Center">OVERDRIVE</Translation>
</Text>
@@ -105,10 +108,20 @@
<Translation Language="GB" Alignment="Center">+2</Translation>
</Text>
</TextGroup>
<TextGroup Id="Unsorted" />
<TextGroup Id="Unsorted">
<Text Id="__SingleUse_U5V0" Alignment="Left" TypographyId="Default">
<Translation Language="GB">100</Translation>
</Text>
<Text Id="textAreaMax" Alignment="Left" TypographyId="Default">
<Translation Language="GB">Max : &lt;d&gt; Hz</Translation>
</Text>
<Text Id="__SingleUse_2C9Q" Alignment="Left" TypographyId="Default">
<Translation Language="GB">&lt;&gt;</Translation>
</Text>
</TextGroup>
</Texts>
<Typographies>
<Typography Id="Default" Font="arial.ttf" Size="20" Bpp="4" IsVector="no" Direction="LTR" FallbackCharacter="?" />
<Typography Id="Default" Font="arial.ttf" Size="20" Bpp="4" IsVector="no" Direction="LTR" FallbackCharacter="?" WidgetWildcardCharacters="-., 0123456789" />
<Typography Id="Large" Font="arial.ttf" Size="40" Bpp="4" IsVector="no" Direction="LTR" FallbackCharacter="?" />
<Typography Id="Small" Font="arial.ttf" Size="10" Bpp="4" IsVector="no" Direction="LTR" FallbackCharacter="?" />
</Typographies>
@@ -0,0 +1,36 @@
#ifndef OSCILLOPRESENTER_HPP
#define OSCILLOPRESENTER_HPP
#include <gui/model/ModelListener.hpp>
#include <mvp/Presenter.hpp>
using namespace touchgfx;
class OscilloView;
class OscilloPresenter : public touchgfx::Presenter, public ModelListener
{
public:
OscilloPresenter(OscilloView& v);
/**
* The activate function is called automatically when this screen is "switched in"
* (ie. made active). Initialization logic can be placed here.
*/
virtual void activate();
/**
* The deactivate function is called automatically when this screen is "switched out"
* (ie. made inactive). Teardown functionality can be placed here.
*/
virtual void deactivate();
virtual ~OscilloPresenter() {}
private:
OscilloPresenter();
OscilloView& view;
};
#endif // OSCILLOPRESENTER_HPP
@@ -0,0 +1,20 @@
#ifndef OSCILLOVIEW_HPP
#define OSCILLOVIEW_HPP
#include <gui_generated/oscillo_screen/OscilloViewBase.hpp>
#include <gui/oscillo_screen/OscilloPresenter.hpp>
class OscilloView : public OscilloViewBase
{
public:
OscilloView();
virtual ~OscilloView() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void handleTickEvent();
virtual void toggleClicked();
protected:
};
#endif // OSCILLOVIEW_HPP
@@ -13,6 +13,7 @@ public:
virtual void tearDownScreen();
virtual void toggleAudioOnOFF();
virtual void slider1Changed(int value);
protected:
};
@@ -0,0 +1,18 @@
#include <gui/oscillo_screen/OscilloView.hpp>
#include <gui/oscillo_screen/OscilloPresenter.hpp>
OscilloPresenter::OscilloPresenter(OscilloView& v)
: view(v)
{
}
void OscilloPresenter::activate()
{
}
void OscilloPresenter::deactivate()
{
}
@@ -0,0 +1,59 @@
#include <gui/oscillo_screen/OscilloView.hpp>
#include <audio_analysis.h>
#include <touchgfx/Unicode.hpp>
OscilloView::OscilloView()
{
}
void OscilloView::setupScreen()
{
OscilloViewBase::setupScreen();
toggleButton1.forceState(AudioAnalysis_IsEnabled());
/* Echelle du graphe en dB (affichage uniquement, pas une mesure calibree) :
* de -80dB (proche du plancher de bruit numerique) a +5dB de marge au-dessus
* du 0dB nominal. */
graph1.setGraphRangeY(-80.0f, 5.0f);
/* Axe X en Hz, de 0 a Fe/2 (24kHz) : ce graphe (statique, points X/Y explicites,
* contrairement au precedent DynamicGraph a increment X automatique) recoit
* directement la frequence de chaque bin avec addDataPoint(x, y). */
graph1.setGraphRangeX(0.0f, (float)AUDIO_ANALYSIS_SAMPLE_RATE_HZ / 2.0f);
}
void OscilloView::tearDownScreen()
{
OscilloViewBase::tearDownScreen();
}
void OscilloView::handleTickEvent()
{
OscilloViewBase::handleTickEvent();
if (!AudioAnalysis_IsEnabled())
{
return;
}
if (AudioAnalysis_Update())
{
const float *magnitudesDb = AudioAnalysis_GetMagnitudesDb();
const float binHz = (float)AUDIO_ANALYSIS_SAMPLE_RATE_HZ / (float)AUDIO_ANALYSIS_FFT_SIZE;
graph1.clear();
for (int i = 0; i < (int)AUDIO_ANALYSIS_NUM_BINS; i++)
{
graph1.addDataPoint((float)i * binHz, magnitudesDb[i]);
}
touchgfx::Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "%d", (int)AudioAnalysis_GetPeakFrequencyHz());
textArea2.setWildcard(textArea2Buffer);
textArea2.invalidate();
}
}
void OscilloView::toggleClicked()
{
AudioAnalysis_SetEnabled(toggleButton1.getState());
}
@@ -10,6 +10,7 @@ void OverviewView::setupScreen()
{
OverviewViewBase::setupScreen();
toggleButton1.forceState(AudioEffects_GetParams()->audio_on_off);
slider1.setValue((int16_t)(AudioEffects_GetParams()->master_volume * 100.0f));
}
void OverviewView::tearDownScreen()
@@ -21,3 +22,15 @@ void OverviewView::toggleAudioOnOFF()
{
AudioEffects_GetParams()->audio_on_off = toggleButton1.getState();
}
void OverviewView::slider1Changed(int value)
{
AudioEffects_GetParams()->master_volume = value / 100.0f;
/* Le volume pilote l'etat marche/arret (0 = off, non nul = on), mais pas
* l'inverse : agir sur le toggle ne doit pas modifier le volume. */
bool en = (value != 0);
AudioEffects_GetParams()->audio_on_off = en;
toggleButton1.forceState(en);
toggleButton1.invalidate();
}