Minor edits
This commit is contained in:
		@@ -1,5 +1,11 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Sleep this many millis after each loop.
 | 
				
			||||||
 | 
					// Prevents absurd cpu usage.
 | 
				
			||||||
 | 
					#define LOOP_SLEEP_MS 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// USB device params
 | 
					// USB device params
 | 
				
			||||||
#define HID_VENDOR_ID 0x3297
 | 
					#define HID_VENDOR_ID 0x3297
 | 
				
			||||||
#define HID_PRODUCT_ID 0x4976
 | 
					#define HID_PRODUCT_ID 0x4976
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -206,10 +206,9 @@ bool Ergodox::read() {
 | 
				
			|||||||
		// If keyboard sends a state packet, parse it.
 | 
							// If keyboard sends a state packet, parse it.
 | 
				
			||||||
		case CMD_SEND_STATE:
 | 
							case CMD_SEND_STATE:
 | 
				
			||||||
			if (animation_mode != read_buf[1]) {
 | 
								if (animation_mode != read_buf[1]) {
 | 
				
			||||||
				spdlog::info("Mode set to {0:x}", read_buf[1]);
 | 
									spdlog::info("Mode set to 0x{0:02x}", read_buf[1]);
 | 
				
			||||||
				animation_mode = read_buf[1];
 | 
									animation_mode = read_buf[1];
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Main code should not parse state packets.
 | 
								// Main code should not parse state packets.
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -119,7 +119,6 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
					buf.update();
 | 
										buf.update();
 | 
				
			||||||
					fft.update(buf);
 | 
										fft.update(buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					hid_buf[0] = CMD_ANIM_DATA_fft;
 | 
					 | 
				
			||||||
					for (size_t i = 0; i < 10; i++) {
 | 
										for (size_t i = 0; i < 10; i++) {
 | 
				
			||||||
						// Get height from fft, apply bottom_skip
 | 
											// Get height from fft, apply bottom_skip
 | 
				
			||||||
						ssize_t h = fft.get_output()[i] - BOTTOM_SKIP;
 | 
											ssize_t h = fft.get_output()[i] - BOTTOM_SKIP;
 | 
				
			||||||
@@ -129,11 +128,11 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
						h = h>KB_RESOLUTION ? KB_RESOLUTION : h;
 | 
											h = h>KB_RESOLUTION ? KB_RESOLUTION : h;
 | 
				
			||||||
						h = h<0 ? 0 : h;
 | 
											h = h<0 ? 0 : h;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						hid_buf[i + 1] = h;
 | 
											hid_buf[i] = h;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
										Dox.write(CMD_ANIM_DATA, hid_buf, Dox.packet_size);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Dox.write(CMD_ANIM_DATA, hid_buf, Dox.packet_size);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				t = std::chrono::steady_clock::now();
 | 
									t = std::chrono::steady_clock::now();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -152,9 +151,16 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
						break;
 | 
											break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			Dox.connect_loop();
 | 
								Dox.connect_loop();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Sleep for a bit so we don't consume
 | 
				
			||||||
 | 
							// 100% of a cpu.
 | 
				
			||||||
 | 
							std::this_thread::sleep_for(
 | 
				
			||||||
 | 
								std::chrono::milliseconds(LOOP_SLEEP_MS)
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mpd_connection_free(conn);
 | 
						mpd_connection_free(conn);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user