#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

int main()
{
	unsigned char buf[256] = {0};
	int i ,cs ,line;
	system("echo 1 > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/chip_value");

	for(int i = 0; i < 198; i++)
	{
		memset(buf,0,256);
		cs = i % 18;
		line = i / 18;
		sprintf(buf,"echo %d %d 1  > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/dot_onoff",line, cs);
		system(buf);
	}

	while(1)
	{
		for(int i = 0; i < 198; i++)
		{
			memset(buf,0,256);
			cs = i % 18;
			line = i / 18;
			sprintf(buf,"echo %d %d 0xff7f > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/dot_pwm_16bits_bri",line, cs);
			system(buf);
		}
		system("echo 300 > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/send_sync");
		sleep(1);

		for(int i = 0; i < 198; i++)
		{
			memset(buf,0,256);
			cs = i % 18;
			line = i / 18;
			sprintf(buf,"echo %d %d 0x101f > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/dot_pwm_16bits_bri",line, cs);
			system(buf);
		}
		system("echo 300 > /sys/devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.0/send_sync");
		sleep(1);

	}
	return 0;

}