From c37774d159c7d916ee8a6471cbffeae1c0499f43 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 6 Nov 2023 19:28:02 +0900 Subject: [PATCH] sony: Add buzzer support --- converter/news_usb/Makefile | 1 + converter/news_usb/README.md | 42 ++++++++++++++++++++++++++++-------- converter/news_usb/matrix.c | 3 +++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/converter/news_usb/Makefile b/converter/news_usb/Makefile index 4d6cfa58..2b48b964 100644 --- a/converter/news_usb/Makefile +++ b/converter/news_usb/Makefile @@ -10,6 +10,7 @@ TARGET_DIR = . # keyboard dependent files SRC = matrix.c \ led.c \ + tone.c \ news.c CONFIG_H = config.h diff --git a/converter/news_usb/README.md b/converter/news_usb/README.md index 3ed5dad9..64bbbb1d 100644 --- a/converter/news_usb/README.md +++ b/converter/news_usb/README.md @@ -2,23 +2,32 @@ Sony NEWS keyboard converter ============================ Sony NEWS is a BSD workstation with 68K/MIPS released in 1987 in Japan. -- http://en.wikipedia.org/wiki/Sony_NEWS -- https://www.sony.net/SonyInfo/CorporateInfo/History/SonyHistory/2-12.html#block3 - This converter allows NEWS keyboard to be connected to modern PC via USB. It works with NWP-5461 and NWP-411A. -How DIP switches work is unknown and you may need to turn all switches off with this converter. - Limitations: -- Speaker/Buzzer is not supported. - LEDs on NWP-5461 is not supported. - -Pics: -- http://imgur.com/a/JyMzw +- Mouse is not supported. Discussion: - https://geekhack.org/index.php?topic=25759 +Resources: +- https://github.com/tmk/tmk_keyboard/wiki/Sony-NEWS + + +Wiring +------ +Use PD2(USART RXD) for 'Keyboard Data' pin and give power with VCC and GND. Other pins are optional and not supported at this point. + + AVR NEWS + ------------------------ + PD2 Keyboard Data + PD3 Keyboard Command + PD4 Mouse Data + PD0 BZ + +Target microcontroller is Atmel ATMega32U2 by default but porting this project to other 8-bit AVR controllers would be easy. + Protocol @@ -42,6 +51,7 @@ For example 0x29 is sent when 'a' key is pressed and 0xA9 when released. +---------------- break flag: sets when released + Scan Codes ---------- ### NWP-5461 @@ -118,3 +128,17 @@ I have three NWP-5461s and GND and FG is connected in one of them for some reaso 8 NC 9 FG NOTE: These are just from my guess and not confirmed. + + + +Buzzer +------ +You can control buzzer using `tone()` and `noTone()`. BZ pin should be connected to PD0. + +- `void tone(unsigned int frequency, unsigned long duration)` +- `void noTone(void)` + +`tone()` sounds buzzer in frequency(in hertz) for duration(in milliseconds). +When giving -1 as duration to `tone()` buzzer makes a sound forever until `noTone()` is called. + +Buzzer is not used by default firmware. diff --git a/converter/news_usb/matrix.c b/converter/news_usb/matrix.c index c92a4888..cd1511c6 100644 --- a/converter/news_usb/matrix.c +++ b/converter/news_usb/matrix.c @@ -58,6 +58,8 @@ void matrix_init(void) return; } +void tone(unsigned int frequency, unsigned long duration); +void noTone(void); uint8_t matrix_scan(void) { uint8_t code; @@ -76,6 +78,7 @@ uint8_t matrix_scan(void) // make code if (!matrix_is_on(ROW(code), COL(code))) { matrix[ROW(code)] |= (1<