Commit a85b55b7 authored by laurentc's avatar laurentc

$FW : fast and small low precision sin cos lib. Switch off (long press)...

$FW : fast and small low precision sin cos lib.  Switch off (long press) really kills it. But now need to unplug to restart.
parent f82f6461
#define M_PI ((float)3.141592654) #define M_PI ((float)3.14159265358979323846f)
#define NB_LEDS_PER_STRIP 40 #define NB_LEDS_PER_STRIP 40
#define NB_LINES 1 #define NB_LINES 1
......
// fast and small
float sinfsm(float x);
float cosfsm(float x);
float tanfsm(float x);
/*
* Auto generated Run-Time-Environment Component Configuration File
* *** Do not modify ! ***
*
* Project: 'ledtube_mini'
* Target: 'ledtube_mini'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
#endif /* RTE_COMPONENTS_H */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<Extensions> <Extensions>
<cExt>*.c</cExt> <cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt> <aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj</oExt> <oExt>*.obj; *.o</oExt>
<lExt>*.lib</lExt> <lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt> <tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt> <pExt>*.plm</pExt>
...@@ -78,18 +78,6 @@ ...@@ -78,18 +78,6 @@
<IsCurrentTarget>1</IsCurrentTarget> <IsCurrentTarget>1</IsCurrentTarget>
</OPTFL> </OPTFL>
<CpuCode>18</CpuCode> <CpuCode>18</CpuCode>
<Books>
<Book>
<Number>0</Number>
<Title>STM32F3-Discovery Web Page (STM32F3-Discovery)</Title>
<Path>http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF254044</Path>
</Book>
<Book>
<Number>1</Number>
<Title>STM32303C-EVAL Web Page (STM32303C-EVAL)</Title>
<Path>http://www.st.com/web/en/catalog/tools/PF252996</Path>
</Book>
</Books>
<DebugOpt> <DebugOpt>
<uSim>0</uSim> <uSim>0</uSim>
<uTrg>1</uTrg> <uTrg>1</uTrg>
...@@ -112,6 +100,7 @@ ...@@ -112,6 +100,7 @@
<tRSysVw>1</tRSysVw> <tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb> <sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime> <sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<nTsel>11</nTsel> <nTsel>11</nTsel>
<sDll></sDll> <sDll></sDll>
<sDllPa></sDllPa> <sDllPa></sDllPa>
...@@ -126,6 +115,11 @@ ...@@ -126,6 +115,11 @@
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon> <pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
</DebugOpt> </DebugOpt>
<TargetDriverDllRegistry> <TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGDARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key> <Key>ARMRTXEVENTFLAGS</Key>
...@@ -139,7 +133,7 @@ ...@@ -139,7 +133,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>ARMDBGFLAGS</Key> <Key>ARMDBGFLAGS</Key>
<Name></Name> <Name>-T0</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
...@@ -154,7 +148,7 @@ ...@@ -154,7 +148,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key> <Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F3xx_256.FLM -FS08000000 -FL010000 -FP0($$Device:STM32F303K8$Flash\STM32F3xx_256.FLM)</Name> <Name>-U-O142 -O2254 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F3xx_256.FLM -FS08000000 -FL010000 -FP0($$Device:STM32F303K8$Flash\STM32F3xx_256.FLM)</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint/>
...@@ -209,6 +203,11 @@ ...@@ -209,6 +203,11 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>time_speed_coeff</ItemText> <ItemText>time_speed_coeff</ItemText>
</Ww> </Ww>
<Ww>
<count>10</count>
<WinNumber>1</WinNumber>
<ItemText>mysin</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<WatchWindow2> <WatchWindow2>
<Ww> <Ww>
...@@ -221,6 +220,21 @@ ...@@ -221,6 +220,21 @@
<WinNumber>2</WinNumber> <WinNumber>2</WinNumber>
<ItemText>raw_out</ItemText> <ItemText>raw_out</ItemText>
</Ww> </Ww>
<Ww>
<count>2</count>
<WinNumber>2</WinNumber>
<ItemText>mysinC</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>2</WinNumber>
<ItemText>mycosC</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>2</WinNumber>
<ItemText>sincoeff</ItemText>
</Ww>
</WatchWindow2> </WatchWindow2>
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
...@@ -244,7 +258,7 @@ ...@@ -244,7 +258,7 @@
<DebugFlag> <DebugFlag>
<trace>0</trace> <trace>0</trace>
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>0</aLwin> <aLwin>1</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>0</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
...@@ -270,6 +284,16 @@ ...@@ -270,6 +284,16 @@
<LintExecutable></LintExecutable> <LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile> <LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto> <bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
</TargetOption> </TargetOption>
</Target> </Target>
...@@ -615,6 +639,18 @@ ...@@ -615,6 +639,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>27</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Src\sinfastsmall.c</PathWithFileName>
<FilenameWithoutPath>sinfastsmall.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
<TargetName>ledtube_mini</TargetName> <TargetName>ledtube_mini</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060061::V5.06 update 1 (build 61)::ARMCC</pCCUsed> <pCCUsed>5060528::V5.06 update 5 (build 528)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption> <TargetOption>
<TargetCommonOption> <TargetCommonOption>
<Device>STM32F303K8</Device> <Device>STM32F303K8</Device>
...@@ -125,47 +126,6 @@ ...@@ -125,47 +126,6 @@
<HexOffset>0</HexOffset> <HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen> <Oh166RecLen>16</Oh166RecLen>
</OPTHX> </OPTHX>
<Simulator>
<UseSimulator>0</UseSimulator>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>1</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<LimitSpeedToRealTime>0</LimitSpeedToRealTime>
<RestoreSysVw>1</RestoreSysVw>
</Simulator>
<Target>
<UseTarget>1</UseTarget>
<LoadApplicationAtStartup>1</LoadApplicationAtStartup>
<RunToMain>1</RunToMain>
<RestoreBreakpoints>1</RestoreBreakpoints>
<RestoreWatchpoints>1</RestoreWatchpoints>
<RestoreMemoryDisplay>1</RestoreMemoryDisplay>
<RestoreFunctions>1</RestoreFunctions>
<RestoreToolbox>1</RestoreToolbox>
<RestoreTracepoints>1</RestoreTracepoints>
<RestoreSysVw>1</RestoreSysVw>
</Target>
<RunDebugAfterBuild>0</RunDebugAfterBuild>
<TargetSelection>11</TargetSelection>
<SimDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
</SimDlls>
<TargetDlls>
<CpuDll></CpuDll>
<CpuDllArguments></CpuDllArguments>
<PeripheralDll></PeripheralDll>
<PeripheralDllArguments></PeripheralDllArguments>
<InitializationFile></InitializationFile>
<Driver>STLink\ST-LINKIII-KEIL_SWO.dll</Driver>
</TargetDlls>
</DebugOption> </DebugOption>
<Utilities> <Utilities>
<Flash1> <Flash1>
...@@ -369,9 +329,12 @@ ...@@ -369,9 +329,12 @@
<v6LangP>0</v6LangP> <v6LangP>0</v6LangP>
<vShortEn>0</vShortEn> <vShortEn>0</vShortEn>
<vShortWch>0</vShortWch> <vShortWch>0</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls> <VariousControls>
<MiscControls>--C99</MiscControls> <MiscControls>--C99</MiscControls>
<Define>USE_HAL_DRIVER,STM32F303x8, POWER_LIMITER, POWER_MANAGER</Define> <Define>USE_HAL_DRIVER,STM32F303x8, POWER_LIMITER, POWER_MANAGER, CCMRAM</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>../Inc; ../Drivers/STM32F3xx_HAL_Driver/Inc; ../Drivers/STM32F3xx_HAL_Driver/Inc/Legacy; ../Drivers/CMSIS/Include; ../Drivers/CMSIS/Device/ST/STM32F3xx/Include</IncludePath> <IncludePath>../Inc; ../Drivers/STM32F3xx_HAL_Driver/Inc; ../Drivers/STM32F3xx_HAL_Driver/Inc/Legacy; ../Drivers/CMSIS/Include; ../Drivers/CMSIS/Device/ST/STM32F3xx/Include</IncludePath>
</VariousControls> </VariousControls>
...@@ -386,6 +349,7 @@ ...@@ -386,6 +349,7 @@
<NoWarn>0</NoWarn> <NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc> <uSurpInc>0</uSurpInc>
<useXO>0</useXO> <useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
...@@ -561,6 +525,11 @@ ...@@ -561,6 +525,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\Src\commands.c</FilePath> <FilePath>..\Src\commands.c</FilePath>
</File> </File>
<File>
<FileName>sinfastsmall.c</FileName>
<FileType>1</FileType>
<FilePath>..\Src\sinfastsmall.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -99,8 +99,8 @@ uint8_t commandRx(int *cmd_id,void *vData, float real_time) ...@@ -99,8 +99,8 @@ uint8_t commandRx(int *cmd_id,void *vData, float real_time)
{ {
if (real_time-time_of_press>2) if (real_time-time_of_press>2)
{ {
*((uint32_t *) vData) = 21; // black // *((uint32_t *) vData) = 21; // black
*cmd_id = CMD_MOD; *cmd_id = CMD_OFF; //CMD_MOD;
time_of_press = real_time+100; // so that we don't send the command again time_of_press = real_time+100; // so that we don't send the command again
return 1; return 1;
} }
......
...@@ -37,6 +37,8 @@ inline uint32_t getRawOffsetXWRollOver(int32_t column,int32_t line) ...@@ -37,6 +37,8 @@ inline uint32_t getRawOffsetXWRollOver(int32_t column,int32_t line)
return 3*(column+line*NB_COLUMNS); return 3*(column+line*NB_COLUMNS);
} }
__attribute__((section("ccmram")))
float fonctionGaussienne(float sigma, float x) float fonctionGaussienne(float sigma, float x)
{ {
return 1.0f/(sqrt(2*M_PI)*sigma)*exp(-x*x/(2*sigma*sigma)); return 1.0f/(sqrt(2*M_PI)*sigma)*exp(-x*x/(2*sigma*sigma));
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
#include "led_driver.h" #include "led_driver.h"
#include "globals.h" #include "globals.h"
#include <string.h> #include <string.h>
#define _USE_MATH_DEFINES
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include "sinfastsmall.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
...@@ -17,74 +19,6 @@ inline uint32_t getRawOffset(uint32_t column,uint32_t line) ...@@ -17,74 +19,6 @@ inline uint32_t getRawOffset(uint32_t column,uint32_t line)
} }
__attribute__((section("ccmram")))
float mysin[360];
float mycos[360];
void generateSinCosTable(void)
{
int i;
for (i=0;i<360;i++)
{
mysin[i] = sin(1.0f*i*M_PI/180);
mycos[i] = cos(1.0f*i*M_PI/180);
}
}
__attribute__((section("ccmram")))
float myfsin(float x)
{
int i;
x = x*180.0f/M_PI;
i = fmod(x,360);
if (i>=360)
crash(CC_CODE_SINCOS);
if (i<0)
{
i+=360;
}
if (i<0)
crash(CC_CODE_SINCOS);
return mysin[i];
}
__attribute__((section("ccmram")))
float myfcos(float x)
{
int i;
x = x*180.0f/M_PI;
i = fmod(x,360);
if (i>=360)
crash(CC_CODE_SINCOS);
if (i<0)
{
i+=360;
}
if (i<0)
crash(CC_CODE_SINCOS);
return mycos[i];
}
/*
float myfsin(float x)
{
return sin(x);
}
float myfcos(float x)
{
return cos(x);
}
*/
__attribute__((section("ccmram"))) __attribute__((section("ccmram")))
...@@ -102,7 +36,7 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -102,7 +36,7 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
if (firstCall) if (firstCall)
{ {
generateSinCosTable(); // generateSinTable();
firstCall = 0; firstCall = 0;
} }
...@@ -123,12 +57,12 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -123,12 +57,12 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
c[0] = u_k[0]*(v_coords[0] - 0.5f); c[0] = u_k[0]*(v_coords[0] - 0.5f);
c[1] = u_k[1]*(v_coords[1] - 0.5f); c[1] = u_k[1]*(v_coords[1] - 0.5f);
v = myfsin( c[0]+u_time); v = sinfsm( c[0]+u_time);
v += myfsin((c[1]+u_time)*0.5f); v += sinfsm((c[1]+u_time)*0.5f);
v += myfsin((c[0]+c[1]+u_time)*0.5f); v += sinfsm((c[0]+c[1]+u_time)*0.5f);
c[0] += u_k[0]*0.5f * myfsin(u_time*0.33333f); c[0] += u_k[0]*0.5f * sinfsm(u_time*0.33333f);
c[1] += u_k[1]*0.5f * myfcos(u_time*0.5f); c[1] += u_k[1]*0.5f * cosfsm(u_time*0.5f);
v += myfsin(sqrt(c[0]*c[0]+c[1]*c[1]+1.0f)+u_time); v += sinfsm(sqrt(c[0]*c[0]+c[1]*c[1]+1.0f)+u_time);
v = v*0.5f; v = v*0.5f;
switch(plasma_type) switch(plasma_type)
...@@ -140,9 +74,9 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -140,9 +74,9 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
case 4: case 4:
case 19: case 19:
case 20: case 20:
s1 = 127.5f*myfsin(M_PI*v)+127.5f; s1 = 127.5f*sinfsm(M_PI*v)+127.5f;
s2 = 127.5f*myfsin(M_PI*v+2.0f/3.0f*M_PI)+127.5f; s2 = 127.5f*sinfsm(M_PI*v+2.0f/3.0f*M_PI)+127.5f;
s4 = 127.5f*myfsin(M_PI*v+4.0f/3.0f*M_PI)+127.5f; s4 = 127.5f*sinfsm(M_PI*v+4.0f/3.0f*M_PI)+127.5f;
break; break;
// type 2 couleurs pures // type 2 couleurs pures
case 2: case 2:
...@@ -153,13 +87,13 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -153,13 +87,13 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
case 12: case 12:
case 17: case 17:
case 14: case 14:
s1 = 127.5f*myfsin(M_PI*v)+127.5f; s1 = 127.5f*sinfsm(M_PI*v)+127.5f;
c1 = 127.5f*myfcos(M_PI*v)+127.5f; c1 = 127.5f*cosfsm(M_PI*v)+127.5f;
break; break;
case 13: case 13:
case 15: case 15:
c[0] = 0.5f+0.5f*myfsin(M_PI*v+4.0f/3.0f*M_PI); c[0] = 0.5f+0.5f*sinfsm(M_PI*v+4.0f/3.0f*M_PI);
break; break;
...@@ -197,8 +131,8 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -197,8 +131,8 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
// Yellow // Yellow
case 4: case 4:
// White Yellow Type // White Yellow Type
raw[raw_offset++] = intensity; //(0.5f+0.5f*myfsin(M_PI*v))*255; raw[raw_offset++] = intensity; //(0.5f+0.5f*sinfsm(M_PI*v))*255;
raw[raw_offset++] = intensity; //(0.5f+0.5f*myfsin(M_PI*v+2.0f/3.0f*M_PI))*255; raw[raw_offset++] = intensity; //(0.5f+0.5f*sinfsm(M_PI*v+2.0f/3.0f*M_PI))*255;
raw[raw_offset++] = (s4*intensity)>>8; raw[raw_offset++] = (s4*intensity)>>8;
break; break;
...@@ -254,7 +188,7 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i ...@@ -254,7 +188,7 @@ uint8_t generatePlasma(uint8_t *raw,float u_time, uint8_t plasma_type, uint8_t i
case 5: case 5:
// BLACK AND WHITE // BLACK AND WHITE
x = 127.5f*myfsin(M_PI*4.0f*v)+127.5f; x = 127.5f*sinfsm(M_PI*4.0f*v)+127.5f;
raw[raw_offset++] = (x*intensity)>>8; raw[raw_offset++] = (x*intensity)>>8;
raw[raw_offset++] = (x*intensity)>>8; raw[raw_offset++] = (x*intensity)>>8;
raw[raw_offset++] = (x*intensity)>>8; raw[raw_offset++] = (x*intensity)>>8;
......
...@@ -202,7 +202,7 @@ int main(void) ...@@ -202,7 +202,7 @@ int main(void)
// Pour qu'il ne se mette pas dmarrer sans notre contrle. // Pour qu'il ne se mette pas dmarrer sans notre contrle.
GPIOA->ODR = 0; GPIOA->ODR = 0;
// tant que la clock n'est pas active, ne sera pas latch (pas vrifi si c'est vraiment latch) // tant que la clock n'est pas active, ne sera pas latch (pas vrifi si c'est vraiment latch)
/* USER CODE END 1 */ /* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/ /* MCU Configuration----------------------------------------------------------*/
...@@ -311,6 +311,7 @@ __HAL_DBGMCU_FREEZE_TIM7(); ...@@ -311,6 +311,7 @@ __HAL_DBGMCU_FREEZE_TIM7();
case CMD_INT : intensity = (uint8_t) *((uint32_t*)(rxWifi_raw)); dynamicGenerator = 1; RunLedToggle(); break; case CMD_INT : intensity = (uint8_t) *((uint32_t*)(rxWifi_raw)); dynamicGenerator = 1; RunLedToggle(); break;
case CMD_OFF : dmaWait(); // sweet stop case CMD_OFF : dmaWait(); // sweet stop
dmaQuickBlack(); // pour viter la rmanence image dmaQuickBlack(); // pour viter la rmanence image
HAL_PWR_EnterSTANDBYMode();
break; break;
} }
} }
......
#define _USE_MATH_DEFINES
#include <math.h>
#include "stm32f3xx_hal.h"
#include "globals.h"
const uint16_t sintab[91]= {
0,571,1143,1714,2285,2855,3425,3993,4560,5125,5689,6252,6812,7370,7927,8480,9031,9580,10125,10667,11206,11742,12274,12803,13327,13847,
14364,14875,15383,15885,16383,16876,17363,17846,18323,18794,19259,19719,20173,20620,21062,21497,21925,22347,22761,23169,23570,23964,24350,
24729,25100,25464,25820,26168,26509,26841,27165,27480,27787,28086,28377,28658,28931,29195,29450,29696,29934,30162,30381,30590,30790,30981,31163,
31335,31497,31650,31793,31927,32050,32164,32269,32363,32448,32522,32587,32642,32687,32722,32747,32762,32767
};
#define sincoeff (1.0f/32767.0f)
// ramen sin[0..89]
#ifdef CCMRAM
__attribute__((section("ccmram")))
#endif
// future optim 2x : sin(90-x) = cos(x) ; sin(90+x) = cos(x); sin(x) = cos(90-x) ; cos(90+x) = -sin(x)
// Optim 2x : sin(x+180)=-sin(x) ; cos(x+180)=-cos(x)
// Optim 2x : cos(180-x)=-cos(x) ; sin(180-x) = sin(x)
float sinfsm(float x)
{
int i;
i = (x*180.0f/M_PI);
i = i % 360;
if (i<0)
i+=360;
// 4 cadrans.
if (i>=270) // 270..359
return -sincoeff*sintab[360-i];
else if (i>=180) // 180..269
return -sincoeff*sintab[i-180];
else if (i>=90) // 90..179
return sincoeff*sintab[180-i];
else // 0..89
return sincoeff*sintab[i];
}
#ifdef CCMRAM
__attribute__((section("ccmram")))
#endif
// future optim 2x : cos(x)= sin(90-x) ; cos(x)=sin(90+x) ; sin(x) = cos(90-x) ; cos(90+x) = -sin(x)
float cosfsm(float x)
{
int i;
i = (x*180.0f/M_PI);
i = i % 360;
if (i<0)
i+=360;
// 4 cadrans.
if (i>=270) // 270..359
return sincoeff*sintab[i-270];
else if (i>=180) // 180..269
return -sincoeff*sintab[270-i]; // sin(180-x) = sin(x)
else if (i>=90) // 90..179
return -sincoeff*sintab[i-90];
else // 0..89
return sincoeff*sintab[90-i];
}
float tanfsm(float x)
{
return sinfsm(x)/cosfsm(x);
}
...@@ -69,23 +69,24 @@ Mcu.Pin7=VP_SYS_VS_Systick ...@@ -69,23 +69,24 @@ Mcu.Pin7=VP_SYS_VS_Systick
Mcu.Pin8=VP_TIM2_VS_ClockSourceINT Mcu.Pin8=VP_TIM2_VS_ClockSourceINT
Mcu.Pin9=VP_TIM2_VS_no_output1 Mcu.Pin9=VP_TIM2_VS_no_output1
Mcu.PinsNb=12 Mcu.PinsNb=12
Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F303K8Tx Mcu.UserName=STM32F303K8Tx
MxCube.Version=4.15.1 MxCube.Version=4.15.1
MxDb.Version=DB.4.0.151 MxDb.Version=DB.4.0.151
NVIC.ADC1_2_IRQn=true\:0\:0\:false\:false\:true NVIC.ADC1_2_IRQn=true\:2\:0\:true\:false\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:false NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:false\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false NVIC.DebugMonitor_IRQn=true\:2\:0\:true\:false\:false\:true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:false NVIC.PendSV_IRQn=true\:1\:0\:true\:false\:false\:true
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false NVIC.SVCall_IRQn=true\:2\:0\:true\:false\:false\:true
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true NVIC.SysTick_IRQn=true\:2\:0\:true\:false\:true\:true
NVIC.TIM6_DAC1_IRQn=true\:5\:0\:true\:false\:true NVIC.TIM6_DAC1_IRQn=true\:5\:0\:true\:false\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:true
PA0.Locked=true PA0.Locked=true
PA0.Signal=GPIO_Output PA0.Signal=GPIO_Output
PA13.Mode=Serial_Wire PA13.Mode=Serial_Wire
...@@ -107,20 +108,14 @@ PB4.GPIO_Label=BOUTON_POUSSOIR ...@@ -107,20 +108,14 @@ PB4.GPIO_Label=BOUTON_POUSSOIR
PB4.GPIO_PuPd=GPIO_PULLUP PB4.GPIO_PuPd=GPIO_PULLUP
PB4.Locked=true PB4.Locked=true
PB4.Signal=GPIO_Input PB4.Signal=GPIO_Input
PCC.Checker=false PinOutPanel.RotationAngle=0
PCC.Line=STM32F303 ProjectManager.AskForMigrate=false
PCC.MCU=STM32F303K(6-8)Tx
PCC.MXVersion=4.15.1
PCC.PartNumber=STM32F303K8Tx
PCC.Seq0=0
PCC.Series=STM32F3
PCC.Temperature=25
PCC.Vdd=3.6
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=2 ProjectManager.CompilerOptimize=2