Skip to content
Snippets Groups Projects
Commit a727cdda authored by jamesimmanuel.magsino@stud.h-da.de's avatar jamesimmanuel.magsino@stud.h-da.de
Browse files

Prep

parent 7a8d6728
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <hardware/i2c.h> #include <hardware/i2c.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "hardware/pwm.h"
const uint8_t init[4] = {0x21, 0xa0, 0xe1, 0x81}; const uint8_t init[4] = {0x21, 0xa0, 0xe1, 0x81};
const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14}; const uint8_t zeile[8] = {0x00, 0x02, 0x04, 0x06, 0x08, 0x10, 0x12, 0x14};
const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; const uint8_t fill[17] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
...@@ -104,6 +104,27 @@ const uint8_t better_matrix[65][17] = { ...@@ -104,6 +104,27 @@ const uint8_t better_matrix[65][17] = {
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0b01111111, 0x00}, {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0b01111111, 0x00},
{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0b11111111, 0x00}, {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0b11111111, 0x00},
}; };
void set_progress(int percentage)
{
int numerator = (percentage * 32) / 100;
for (int i = 0; i <= numerator; i++)
{
i2c_write_blocking(i2c_default, 0x70, better_matrix[i], 17, false);
// sleep
// for (int j = 0; j < 100000; j++)
// {
// volatile int i = 0;
// }
}
}
int a = 0;
void callback()
{
a = 1;
}
int main() int main()
{ {
// clock enable: 100000 baud (bit/s) // clock enable: 100000 baud (bit/s)
...@@ -130,27 +151,33 @@ int main() ...@@ -130,27 +151,33 @@ int main()
i2c_write_blocking(i2c_default, 0x70, empty, 17, false); i2c_write_blocking(i2c_default, 0x70, empty, 17, false);
for (int i = 0; i <= 64; i++) set_progress(200);
{ set_progress(30);
i2c_write_blocking(i2c_default, 0x70, better_matrix[i], 17, false);
// sleep gpio_set_function(28, GPIO_FUNC_PWM);
for (int j = 0; j < 1000000; j++)
{
volatile int i = 0;
}
}
for (int i = 64; i >= 0; i--) uint slice_num = pwm_gpio_to_slice_num(28);
{
i2c_write_blocking(i2c_default, 0x70, better_matrix[i], 17, false);
// sleep // 133 Mhz / 133 = 1 Mhz => 1 cycle = 1 us
for (int j = 0; j < 1000000; j++) // 10 mikrosekunden
{ pwm_set_clkdiv(slice_num, 133);
volatile int i = 0; pwm_set_wrap(slice_num, 65000);
} pwm_set_chan_level(slice_num, PWM_CHAN_A, 10);
} pwm_set_enabled(slice_num, true);
uint test = 500;
set_progress(0);
uint another_slice_num = pwm_gpio_to_slice_num(27);
// 65000 * 133 * 10^6 10 meters
// 65000 max cycles
pwm_set_clkdiv(another_slice_num, 133);
pwm_set_wrap(another_slice_num, 65000);
pwm_set_clkdiv_mode(another_slice_num, PWM_DIV_B_HIGH);
pwm_set_enabled(slice_num, true);
int b = 7;
gpio_set_irq_enabled_with_callback(27, GPIO_IRQ_EDGE_FALL, true, callback);
set_progress(100);
return 0; return 0;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment