JGAurora A5S & A1 touch support (#14768)

This commit is contained in:
pinchies
2019-07-31 08:08:11 +10:00
committed by Scott Lahteine
parent c1b99c43b6
commit d98b9d54f1
13 changed files with 131 additions and 115 deletions

View File

@ -89,6 +89,8 @@ static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
);
}
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
static inline void pwm_details(const pin_t pin) {
if (PWM_PIN(pin)) {
timer_dev * const tdev = PIN_MAP[pin].timer_device;

View File

@ -25,6 +25,8 @@
#include <libmaple/stm32.h>
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
#include "HAL_sdio_STM32F1.h"

View File

@ -57,7 +57,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
case 3: irq_num = NVIC_TIMER3; break;
case 4: irq_num = NVIC_TIMER4; break;
case 5: irq_num = NVIC_TIMER5; break;
#ifdef STM32_HIGH_DENSITY
#if ENABLED(STM32_HIGH_DENSITY)
// 6 & 7 are basic timers, avoid them
case 8: irq_num = NVIC_TIMER8_CC; break;
#endif

View File

@ -119,7 +119,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __DSB(void) {
#define FSMC_CS_NE1 PD7
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
#define FSMC_CS_NE2 PG9
#define FSMC_CS_NE3 PG10
#define FSMC_CS_NE4 PG12
@ -151,7 +151,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __DSB(void) {
#define FSMC_RS_A22 PE6
#define FSMC_RS_A23 PE2
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
#define FSMC_RS_A24 PG13
#define FSMC_RS_A25 PG14
#endif
@ -173,7 +173,7 @@ void LCD_IO_Init(uint8_t cs, uint8_t rs) {
switch (cs) {
case FSMC_CS_NE1: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION1; break;
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
case FSMC_CS_NE2: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION2; break;
case FSMC_CS_NE3: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION3; break;
case FSMC_CS_NE4: controllerAddress = (uint32_t)FSMC_NOR_PSRAM_REGION4; break;
@ -184,7 +184,7 @@ void LCD_IO_Init(uint8_t cs, uint8_t rs) {
#define _ORADDR(N) controllerAddress |= (_BV32(N) - 2)
switch (rs) {
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
case FSMC_RS_A0: _ORADDR( 1); break;
case FSMC_RS_A1: _ORADDR( 2); break;
case FSMC_RS_A2: _ORADDR( 3); break;
@ -210,7 +210,7 @@ void LCD_IO_Init(uint8_t cs, uint8_t rs) {
case FSMC_RS_A21: _ORADDR(22); break;
case FSMC_RS_A22: _ORADDR(23); break;
case FSMC_RS_A23: _ORADDR(24); break;
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
case FSMC_RS_A24: _ORADDR(25); break;
case FSMC_RS_A25: _ORADDR(26); break;
#endif
@ -242,7 +242,7 @@ void LCD_IO_Init(uint8_t cs, uint8_t rs) {
gpio_set_mode(PIN_MAP[cs].gpio_device, PIN_MAP[cs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_CS_NEx
gpio_set_mode(PIN_MAP[rs].gpio_device, PIN_MAP[rs].gpio_bit, GPIO_AF_OUTPUT_PP); //FSMC_RS_Ax
#ifdef STM32_XL_DENSITY
#if ENABLED(STM32_XL_DENSITY)
FSMC_NOR_PSRAM4_BASE->BCR = FSMC_BCR_WREN | FSMC_BCR_MTYP_SRAM | FSMC_BCR_MWID_16BITS | FSMC_BCR_MBKEN;
FSMC_NOR_PSRAM4_BASE->BTR = (FSMC_DATA_SETUP_TIME << 8) | FSMC_ADDRESS_SETUP_TIME;
#else // PSRAM1 for STM32F103V (high density)

View File

@ -63,9 +63,9 @@ void XPT2046::init(void) {
uint8_t XPT2046::read_buttons() {
int16_t tsoffsets[4] = { 0 };
static uint32_t timeout = 0;
if (PENDING(millis(), timeout)) return 0;
timeout = millis() + 250;
static uint32_t touchtimeout = 0;
if (PENDING(millis(), touchtimeout)) return 0;
touchtimeout = millis() + 80; // ideally want to set this lower for the games... 30 or 40.
if (tsoffsets[0] + tsoffsets[1] == 0) {
// Not yet set, so use defines as fallback...
@ -82,12 +82,11 @@ uint8_t XPT2046::read_buttons() {
y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
if (y < 185 || y > 224) return 0;
if (WITHIN(x, 21, 98)) encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 121, 198)) encoderDiff = ENCODER_STEPS_PER_MENU_ITEM * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 221, 298)) return EN_C;
if (y < 175 || y > 234) return 0;
if (WITHIN(x, 11, 109)) encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 111, 209)) encoderDiff = ENCODER_STEPS_PER_MENU_ITEM * ENCODER_PULSES_PER_STEP;
else if (WITHIN(x, 211, 309)) return EN_C;
return 0;
}
@ -96,7 +95,7 @@ bool XPT2046::isTouched() {
#if PIN_EXISTS(TOUCH_INT)
READ(TOUCH_INT_PIN) != HIGH
#else
getInTouch(XPT2046_Z1) >= XPT2046_Z1_TRESHHOLD
getInTouch(XPT2046_Z1) >= XPT2046_Z1_THRESHOLD
#endif
);
}

View File

@ -34,7 +34,9 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40
};
#define XPT2046_Z1_TRESHHOLD 10
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif
class XPT2046 {
public:

View File

@ -463,7 +463,7 @@
#elif MB(BIGTREE_SKR_E3_DIP)
#include "stm32/pins_BIGTREE_SKR_E3_DIP.h" // STM32F1 env:BIGTREE_SKR_MINI
#elif MB(JGAURORA_A5S_A1)
#include "stm32/pins_JGAURORA_A5S_A1.h" // STM32F1 env:JGAURORA_A5S_A1
#include "stm32/pins_JGAURORA_A5S_A1.h" // STM32F1 env:jgaurora_a5s_a1
#elif MB(FYSETC_AIO_II)
#include "stm32/pins_FYSETC_AIO_II.h" // STM32F1 env:fysetc_STM32F1
#elif MB(FYSETC_CHEETAH)

View File

@ -22,35 +22,30 @@
#pragma once
/**
* 2017 Victor Perez Marlin for stm32f1 test
* 2018 Modified by Pablo Crespo for Morpheus Board (https://github.com/pscrespo/Morpheus-STM32)
* 2019 Modified by Roberto Mariani & Samuel Pinches for JGAurora A5S & A1 Board.
* ╦╔═╗╔═╗┬ ┬┬─┐┌─┐┬─┐┌─┐╔═╗┌─┐┬─┐┬ ┬┌┬┐ ┌─┐┌─┐┌┬┐
* ║║ ╦╠═╣│ │├┬┘│ │├┬┘├─┤╠╣ │ │├┬┘│ ││││ │ │ ││││
* ╚╝╚═╝╩ ╩└─┘┴└─└─┘┴└─┴ ┴╚ └─┘┴└─└─┘┴ ┴o└─┘└─┘┴ ┴
* Pin assignments for 32-bit JGAurora A5S & A1
*/
/**
* JGAurora A5S A1 Board pin assignments
*/
#ifndef __STM32F1__
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
#elif HOTENDS > 1 || E_STEPPERS > 1
#error "JGAurora 32-bit board only supports 1 hotend / E-stepper. Comment out this line to continue."
#endif
#define BOARD_NAME "JGAurora A5S A1 board"
// #define STM32_XL_DENSITY // required, but should be set by platformio flags, not here! (why? not sure.)
//#define MCU_STM32F103ZE // not yet required
#define STM32_XL_DENSITY
// #define MCU_STM32F103ZE // not yet required
// Enable EEPROM Emulation for this board, so that we don't overwrite factory data
// #define I2C_EEPROM // AT24C64
// #define E2END 0x7FFF // 64KB
// Enable EEPROM Emulation for this board
//#define FLASH_EEPROM_EMULATION 1
//#define E2END 0xFFF // 4KB
//#define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1)
//#define EEPROM_CHITCHAT
//#define DEBUG_EEPROM_READWRITE
// #define FLASH_EEPROM_EMULATION 1
// #define E2END 0xFFF // 4KB
// #define E2END uint32(EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE * 2) - 1)
// #define EEPROM_CHITCHAT
// #define DEBUG_EEPROM_READWRITE
//
// Limit Switches
@ -58,6 +53,9 @@
#define X_STOP_PIN PC6
#define Y_STOP_PIN PG8
#define Z_STOP_PIN PG7
//#define X_MAX_PIN PC5
//#define Y_MAX_PIN PC4
//#define Z_MAX_PIN PB0
//
// Steppers
@ -96,7 +94,6 @@
#define FAN_PIN PA1
#define PS_ON_PIN PA0
#define FIL_RUNOUT_PIN PC7
//
@ -106,6 +103,10 @@
#define FSMC_CS_PIN PD7
#define FSMC_RS_PIN PG0
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
//
// SD Card
//
@ -125,5 +126,3 @@
#define TOUCH_CS_PIN PA4
#define TOUCH_INT_PIN PC4
#endif
#define NO_PAUSE_AFTER_PRINT