Browse Source

Fix codacy issues

ech1560
Xose Pérez 6 years ago
parent
commit
d4e5302a81
5 changed files with 26 additions and 26 deletions
  1. +3
    -2
      code/espurna/ir.ino
  2. +19
    -17
      code/espurna/pwm.c
  3. +0
    -4
      code/extra_scripts.py
  4. +2
    -2
      code/gulpfile.js
  5. +2
    -1
      code/ota.py

+ 3
- 2
code/espurna/ir.ino View File

@ -23,12 +23,13 @@ unsigned long _ir_last_toggle = 0;
void _irProcessCode(unsigned long code, unsigned char type) {
// Check valid code
unsigned long last_code = 0;
unsigned long last_time = 0;
static unsigned long last_code = 0;
static unsigned long last_time = 0;
if (code == 0xFFFFFFFF) return;
if (type == 0xFF) return;
if ((last_code == code) && (millis() - last_time < IR_DEBOUNCE)) return;
last_code = code;
last_time = millis();
DEBUG_MSG_P(PSTR("[IR] Received 0x%08X (%d)\n"), code, type);
#if IR_BUTTON_SET > 0


+ 19
- 17
code/espurna/pwm.c View File

@ -19,27 +19,29 @@
/* Set the following three defines to your needs */
#ifndef SDK_PWM_PERIOD_COMPAT_MODE
#define SDK_PWM_PERIOD_COMPAT_MODE 0
#define SDK_PWM_PERIOD_COMPAT_MODE 0
#endif
#ifndef PWM_MAX_CHANNELS
#define PWM_MAX_CHANNELS 8
#define PWM_MAX_CHANNELS 8
#endif
#define PWM_DEBUG 0
#define PWM_USE_NMI 1
#define PWM_DEBUG 0
#define PWM_USE_NMI 1
/* no user servicable parts beyond this point */
#define PWM_MAX_TICKS 0x7fffff
#define PWM_MAX_TICKS 0x7fffff
#if SDK_PWM_PERIOD_COMPAT_MODE
#define PWM_PERIOD_TO_TICKS(x) (x * 0.2)
#define PWM_DUTY_TO_TICKS(x) (x * 5)
#define PWM_MAX_DUTY (PWM_MAX_TICKS * 0.2)
#define PWM_MAX_PERIOD (PWM_MAX_TICKS * 5)
#define PWM_PERIOD_TO_TICKS(x) (x * 0.2)
#define PWM_DUTY_TO_TICKS(x) (x * 5)
#define PWM_MAX_DUTY (PWM_MAX_TICKS * 0.2)
#define PWM_MAX_PERIOD (PWM_MAX_TICKS * 5)
#else
#define PWM_PERIOD_TO_TICKS(x) (x)
#define PWM_DUTY_TO_TICKS(x) (x)
#define PWM_MAX_DUTY PWM_MAX_TICKS
#define PWM_MAX_PERIOD PWM_MAX_TICKS
#define PWM_PERIOD_TO_TICKS(x) (x)
#define PWM_DUTY_TO_TICKS(x) (x)
#define PWM_MAX_DUTY PWM_MAX_TICKS
#define PWM_MAX_PERIOD PWM_MAX_TICKS
#endif
#include <c_types.h>
@ -48,8 +50,8 @@
#include "libs/pwm.h"
// from SDK hw_timer.c
#define TIMER1_DIVIDE_BY_16 0x0004
#define TIMER1_ENABLE_TIMER 0x0080
#define TIMER1_DIVIDE_BY_16 0x0004
#define TIMER1_ENABLE_TIMER 0x0080
struct pwm_phase {
uint32_t ticks; ///< delay until next phase, in 200ns units
@ -400,7 +402,7 @@ pwm_start(void)
void ICACHE_FLASH_ATTR
pwm_set_duty(uint32_t duty, uint8_t channel)
{
if (channel > PWM_MAX_CHANNELS)
if (channel >= PWM_MAX_CHANNELS)
return;
if (duty > PWM_MAX_DUTY)
@ -412,7 +414,7 @@ pwm_set_duty(uint32_t duty, uint8_t channel)
uint32_t ICACHE_FLASH_ATTR
pwm_get_duty(uint8_t channel)
{
if (channel > PWM_MAX_CHANNELS)
if (channel >= PWM_MAX_CHANNELS)
return 0;
return pwm_duty[channel];
}


+ 0
- 4
code/extra_scripts.py View File

@ -4,11 +4,7 @@ from __future__ import print_function
import os
import sys
from subprocess import call
import click
from platformio import util
import distutils.spawn
Import("env", "projenv")


+ 2
- 2
code/gulpfile.js View File

@ -72,8 +72,8 @@ var toHeader = function(name, debug) {
output += '#define ' + safename + '_len ' + source.contents.length + '\n';
output += 'const uint8_t ' + safename + '[] PROGMEM = {';
for (var i=0; i<source.contents.length; i++) {
if (i > 0) output += ',';
if (0 === (i % 20)) output += '\n';
if (i > 0) { output += ',' };
if (0 === (i % 20)) { output += '\n' };
output += '0x' + ('00' + source.contents[i].toString(16)).slice(-2);
}
output += '\n};';


+ 2
- 1
code/ota.py View File

@ -39,6 +39,8 @@ def on_service_state_change(zeroconf, service_type, name, state_change):
Callback that adds discovered devices to "devices" list
"""
global discover_last
if state_change is ServiceStateChange.Added:
discover_last = time.time()
info = zeroconf.get_service_info(service_type, name)
@ -146,7 +148,6 @@ def get_board_by_mac(mac):
"""
Returns the required data to flash a given board
"""
hostname = hostname.lower()
for device in devices:
if device.get('mac', '').lower() == mac:
board = {}


Loading…
Cancel
Save