aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lufa/Projects/TempDataLogger/Config/AppConfig.h
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-07-06 23:00:05 -0500
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-07-06 21:00:05 -0700
commitd16db6936715a98b6ae769463d5ccafab25b7203 (patch)
treeffb87385b4126a69b85de1074463b8045ea716d5 /lib/lufa/Projects/TempDataLogger/Config/AppConfig.h
parenta07da6e2452cd17699a01530f5435272ab6a732f (diff)
downloadfirmware-d16db6936715a98b6ae769463d5ccafab25b7203.tar.gz
firmware-d16db6936715a98b6ae769463d5ccafab25b7203.tar.bz2
firmware-d16db6936715a98b6ae769463d5ccafab25b7203.zip
Added mod carry over from press to release. (#5866)
Update docs/feature_space_cadet.md Co-Authored-By: fauxpark <fauxpark@gmail.com>
Diffstat (limited to 'lib/lufa/Projects/TempDataLogger/Config/AppConfig.h')
0 files changed, 0 insertions, 0 deletions
139' href='#n139'>139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
/* Copyright 2017 Jack Humbert
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "process_terminal.h"
#include <string.h>
#include "version.h"
#include <stdio.h>
#include <math.h>

#ifndef CMD_BUFF_SIZE
  #define CMD_BUFF_SIZE 5
#endif


bool terminal_enabled = false;
char buffer[80] = "";
char cmd_buffer[CMD_BUFF_SIZE][80];
bool cmd_buffer_enabled = true; //replace with ifdef?
char newline[2] = "\n";
char arguments[6][20];
bool firstTime = true;

short int current_cmd_buffer_pos = 0; //used for up/down arrows - keeps track of where you are in the command buffer

__attribute__ ((weak))
const char terminal_prompt[8] = "> ";

#ifdef AUDIO_ENABLE
    #ifndef TERMINAL_SONG
        #define TERMINAL_SONG SONG(TERMINAL_SOUND)
    #endif
    float terminal_song[][2] = TERMINAL_SONG;
    #define TERMINAL_BELL() PLAY_SONG(terminal_song)
#else
    #define TERMINAL_BELL()
#endif

__attribute__ ((weak))
const char keycode_to_ascii_lut[58] = {
    0, 0, 0, 0,
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
    'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t',
    ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'
};

__attribute__ ((weak))
const char shifted_keycode_to_ascii_lut[58] = {
    0, 0, 0, 0,
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
    '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', 0, 0, 0, '\t',
    ' ', '_', '+', '{', '}', '|', 0, ':', '\'', '~', '<', '>', '?'
};

struct stringcase {
    char* string;
    void (*func)(void);
} typedef stringcase;

void enable_terminal(void) {
    terminal_enabled = true;
    strcpy(buffer, "");
    memset(cmd_buffer,0,CMD_BUFF_SIZE * 80);
    for (int i = 0; i < 6; i++)
        strcpy(arguments[i], "");
    // select all text to start over
    // SEND_STRING(SS_LCTRL("a"));
    send_string(terminal_prompt);
}

void disable_terminal(void) {
    terminal_enabled = false;
    SEND_STRING("\n");
}

void push_to_cmd_buffer(void) {
if (cmd_buffer_enabled) {
    if (cmd_buffer == NULL) {
      return;
    } else {
    if (firstTime) {
     firstTime = false;
     strcpy(cmd_buffer[0],buffer);
     return;
   }

   for (int i= CMD_BUFF_SIZE - 1;i > 0 ;--i) {
      strncpy(cmd_buffer[i],cmd_buffer[i-1],80);
   }

   strcpy(cmd_buffer[0],buffer);

   return;
    }
  }
}

void terminal_about(void) {
    SEND_STRING("QMK Firmware\n");
    SEND_STRING("  v");
    SEND_STRING(QMK_VERSION);
    SEND_STRING("\n"SS_TAP(X_HOME)"  Built: ");
    SEND_STRING(QMK_BUILDDATE);
    send_string(newline);
    #ifdef TERMINAL_HELP
        if (strlen(arguments[1]) != 0) {
            SEND_STRING("You entered: ");
            send_string(arguments[1]);
            send_string(newline);
        }
    #endif
}

void terminal_help(void);

extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];

void terminal_keycode(void) {
    if (strlen(arguments[1]) != 0 && strlen(arguments[2]) != 0 && strlen(arguments[3]) != 0) {
        char keycode_dec[5];
        char keycode_hex[5];
        uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
        uint16_t row = strtol(arguments[2], (char **)NULL, 10);
        uint16_t col = strtol(arguments[3], (char **)NULL, 10);
        uint16_t keycode = pgm_read_word(&keymaps[layer][row][col]);
        itoa(keycode, keycode_dec, 10);
        itoa(keycode, keycode_hex, 16);
        SEND_STRING("0x");
        send_string(keycode_hex);
        SEND_STRING(" (");
        send_string(keycode_dec);
        SEND_STRING(")\n");
    } else {
        #ifdef TERMINAL_HELP
            SEND_STRING("usage: keycode <layer> <row> <col>\n");
        #endif
    }
}

void terminal_keymap(void) {
    if (strlen(arguments[1]) != 0) {
        uint16_t layer = strtol(arguments[1], (char **)NULL, 10);
        for (int r = 0; r < MATRIX_ROWS; r++) {
            for (int c = 0; c < MATRIX_COLS; c++) {
                uint16_t keycode = pgm_read_word(&keymaps[layer][r][c]);
                char keycode_s[8];
                sprintf(keycode_s, "0x%04x,", keycode);
                send_string(keycode_s);
            }
            send_string(newline);
        }
    } else {
        #ifdef TERMINAL_HELP
            SEND_STRING("usage: keymap <layer>\n");
        #endif
    }
}

void print_cmd_buff(void) {
  /* without the below wait, a race condition can occur wherein the
   buffer can be printed before it has been fully moved */
  wait_ms(250);
  for(int i=0;i<CMD_BUFF_SIZE;i++){
    char tmpChar = ' ';
    itoa(i ,&tmpChar,10);
    const char * tmpCnstCharStr = &tmpChar; //because sned_string wont take a normal char *