<commit_before>#ifndef GUI_H__
#define GUI_H__

#include <stdlib.h>

#include "WProgram.h"

#ifdef MIDIDUINO_USE_GUI

class Encoder {
 protected:
  int old, cur;
  char name[4];

 public:
  Encoder(char *_name = NULL);
  void clear();
  char *getName() { return name; }
  void setName(char *_name) {
    if (_name != NULL)
      m_strncpy_fill(name, _name, 4);
  }
  virtual void update(encoder_t *enc);
  virtual void handle(int val);
  void checkHandle() {
    if (cur != old) {
      handle(cur);
    }
    
    old = cur;
  }
  bool hasChanged() {
    return old != cur;
  }
  int getValue() {
    return cur;
  }
  int getOldValue() {
    return old;
  }
  void setValue(int value) {
    old = cur = value;
  }
};

class RangeEncoder : public Encoder {
 public:
  int min;
  int max;

 RangeEncoder(int _max = 127, int _min = 0, char *_name = NULL, int init = 0) : Encoder(_name) {
    if (_min > _max) {
      min = _max;
      max = _min;
    } else {
      min = _min;
      max = _max;<commit_msg>only update current value when setting new value, maybe that was the problem with the md encoders<commit_after>#ifndef GUI_H__
#define GUI_H__

#include <stdlib.h>

#include "WProgram.h"

#ifdef MIDIDUINO_USE_GUI

class Encoder {
 protected:
  int old, cur;
  char name[4];

 public:
  Encoder(char *_name = NULL);
  void clear();
  char *getName() { return name; }
  void setName(char *_name) {
    if (_name != NULL)
      m_strncpy_fill(name, _name, 4);
  }
  virtual void update(encoder_t *enc);
  virtual void handle(int val);
  void checkHandle() {
    if (cur != old) {
      handle(cur);
    }
    
    old = cur;
  }
  bool hasChanged() {
    return old != cur;
  }
  int getValue() {
    return cur;
  }
  int getOldValue() {
    return old;
  }
  void setValue(int value) {
    cur = value;
  }
};

class RangeEncoder : public Encoder {
 public:
  int min;
  int max;

 RangeEncoder(int _max = 127, int _min = 0, char *_name = NULL, int init = 0) : Encoder(_name) {
    if (_min > _max) {
      min = _max;
      max = _min;
    } else {
      min = _min;
      max = _max;
{'fraction_non_alphanumeric': 0.12535885167464114, 'fraction_numerical': 0.0066985645933014355, 'mean_word_length': 2.61139896373057, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2201382', 'n_tokens_mistral': 794, 'n_tokens_neox': 758, 'n_words': 226}