Guest User

Untitled

a guest
May 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. const int led_t = 360;
  2. const int led_x = 100;
  3. int[,] r_preview = new int[led_t,led_x];
  4. int[,] g_preview = new int[led_t,led_x];
  5. int[,] b_preview = new int[led_t,led_x];
  6.  
  7. //Assign some values to r_preview, g_preview, b_preview...
  8.  
  9. private void Send_LED_Data(object sender, SerialDataReceivedEventArgs e) //Function for serial LED communication
  10. {
  11. SerialPort sp = (SerialPort)sender;
  12. if (sp.ReadChar() == 'a')
  13. {
  14. byte[] data = new byte[3*led_x+1];
  15. data[0] = (byte)(c_interval);
  16. for (int i = 0; i < led_x; i++)
  17. {
  18. data[i + 1] = (byte)(r_preview[index_of_array, i]);
  19. data[i + led_x+1] = (byte)(g_preview[index_of_array, i]);
  20. data[i + 2*led_x+1] = (byte)(b_preview[index_of_array, i]);
  21. }
  22. sp.Write(data, 0, 3*led_x+1);
  23. index_of_array=(index_of_array+1)%led_t;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment