Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: LUTs/LUTS.cpp
- Revision:
- 15:1c67f064278e
- Parent:
- 14:9cfe0041cc4e
- Child:
- 19:08862f49cd9e
diff -r 9cfe0041cc4e -r 1c67f064278e LUTs/LUTS.cpp
--- a/LUTs/LUTS.cpp Tue May 19 15:04:33 2020 +0000
+++ b/LUTs/LUTS.cpp Tue May 19 18:38:33 2020 +0000
@@ -50,17 +50,35 @@
tri_wavtable[0]=0;
rise_t=(pulsewidth*1024/100);
rise_tu=(uint16_t)rise_t;
- fall_tu=1-rise_tu;
+ fall_tu=1024-rise_tu;
dif=65536/rise_t;
dif_u=(uint16_t)dif;
+
+ #ifdef SLOW_TIME
+ printf("PRINTING TRI WAVETABLE Values\n");
+ printf("PW= %d \n",pulsewidth);
+ printf("Rise Samples= %u\n", rise_tu);
+ printf("Fall Samples= %u\n", fall_tu);
+ printf("UP sample dif= %u\n", dif_u);
+ #endif
+
for (int i=1; i<=rise_tu; i++) {
tri_wavtable[i]=tri_wavtable[i-1]+dif_u;
}
dif=65536/fall_tu;
dif_u=(uint16_t)dif;
- for (int i=rise_t+1; i<1024; i++) {
- tri_wavtable[i]=tri_wavtable[i-1]-dif_u;
+
+ #ifdef SLOW_TIME
+ printf("down sample dif= %u\n", dif_u);
+ #endif
+
+ for (int i=rise_tu; i<1024; i++) {
+ tri_wavtable[i]=65535-((i-rise_tu)*dif_u);
}
+
+ #ifdef SLOW_TIME
+ tri_wav_results();
+ #endif
}
@@ -80,6 +98,13 @@
}
}
+void LUTs::tri_wav_results() {
+ printf("TRI_WAV_RESULTS:\n");
+ printf("i,out\n");
+ for (i=0; i<=1024; i=i+64) {
+ printf("%d, %u\n",i,tri_wavtable[i]);
+ }
+ }
/*
uint16_t get_sin(int i)