<commit_before>package com.ebertp;

import com.tinkerforge.BrickletLCD20x4;
import com.tinkerforge.NotConnectedException;
import com.tinkerforge.TimeoutException;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WeatherViewLcd24x4 implements Runnable {

  private final WeatherModel weatherModell;
  private final BrickletLCD20x4 lcd;
  private final DecimalFormat df1 = new DecimalFormat("#.0");
  private final DecimalFormat df0 = new DecimalFormat("#");
  private SimpleDateFormat sdf1 = new SimpleDateFormat("d.MMMM");
  private SimpleDateFormat sdf2 = new SimpleDateFormat("EE HH:mm:ss");
  private boolean timeOrdate = true;

  public WeatherViewLcd24x4(WeatherModel weatherModell, BrickletLCD20x4 lcd) {
    this.weatherModell = weatherModell;
    this.lcd = lcd;
    final Thread t = new Thread(this);
    t.start();
  }

  public void paint() {
    try {
      lcd.clearDisplay();
      switchBacklightOffAtNight();

      lcd.writeLine((short) 0, (short) 12, (int) Math.round(weatherModell.getAirPressure()) + " hPa");
      lcd.writeLine((short) 0, (short) 0, df1.format(weatherModell.getHumdidity()) + " %RH");
      lcd.writeLine((short) 1, (short) 0, df1.format(weatherModell.getTempIn()) + " C");
      lcd.writeLine((short) 2, (short) 0, df0.format(weatherModell.getIllumination()) + " lx  ");

      Date d = new Date();
      String message;
      if (timeOrdate) {
        message = sdf1.format(d);
      } else {
        message = sdf2.format(d);
      }
      // FIXME bug with long month names like september
      lcd.writeLine((short) 1, (short) 8, message);

      lcd.writeLine((short) 3, (short) 0, utf16ToKS0066U(weatherModell.getForecast()));
      timeOrdate = !timeOrdate;

    } catch (TimeoutException | NotConnectedException e) {
      log.error("paint", e);
    }
  }

  private void switchBacklightOffAtNight() {
    int h = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    try {
      if ((h > 5) && (h < 22)) {
        lcd.backlightOn();
      } else {
        lcd.backlightOff();
      }
    } catch (TimeoutException | NotConnectedException e) {
      log.error("switchBacklightOffAtNight", e);
    }
  }

  @Override
  public void run() {<commit_msg>delete row before writing on it<commit_after>package com.ebertp;

import com.tinkerforge.BrickletLCD20x4;
import com.tinkerforge.NotConnectedException;
import com.tinkerforge.TimeoutException;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WeatherViewLcd24x4 implements Runnable {

  private final WeatherModel weatherModell;
  private final BrickletLCD20x4 lcd;
  private final DecimalFormat df1 = new DecimalFormat("#.0");
  private final DecimalFormat df0 = new DecimalFormat("#");
  private SimpleDateFormat sdf1 = new SimpleDateFormat("d.MMMM");
  private SimpleDateFormat sdf2 = new SimpleDateFormat("EE HH:mm:ss");
  private boolean timeOrdate = true;

  public WeatherViewLcd24x4(WeatherModel weatherModell, BrickletLCD20x4 lcd) {
    this.weatherModell = weatherModell;
    this.lcd = lcd;
    final Thread t = new Thread(this);
    t.start();
  }

  public void paint() {
    try {
      lcd.clearDisplay();
      switchBacklightOffAtNight();

      lcd.writeLine((short) 0, (short) 12, (int) Math.round(weatherModell.getAirPressure()) + " hPa");
      lcd.writeLine((short) 0, (short) 0, df1.format(weatherModell.getHumdidity()) + " %RH");
      lcd.writeLine((short) 1, (short) 0, df1.format(weatherModell.getTempIn()) + " C");
      lcd.writeLine((short) 2, (short) 0, df0.format(weatherModell.getIllumination()) + " lx  ");

      Date d = new Date();
      String message;
      if (timeOrdate) {
        message = sdf1.format(d);
      } else {
        message = sdf2.format(d);
      }
      lcd.writeLine((short) 1, (short) 8, message);

      String forcast = utf16ToKS0066U(weatherModell.getForecast());
      int l = forcast.length();
      if(forcast.length()<24) {
        for (int i = 0; i < (24 - l); i++) {
          forcast = forcast + " ";
        }
      }
      lcd.writeLine((short) 3, (short) 0, forcast);
      timeOrdate = !timeOrdate;

    } catch (TimeoutException | NotConnectedException e) {
      log.error("paint", e);
    }
  }

  private void switchBacklightOffAtNight() {
    int h = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    try {
      if ((h > 5) && (h < 22)) {
        lcd.backlightOn();
      } else {
        lcd.backlightOff();
      }
    } catch (TimeoutException | NotConnectedException e) {
      log.error("switchBacklightOffAtNight", e);
    }
  }

  @Override
  public void run() {
{'fraction_non_alphanumeric': 0.12859524802000832, 'fraction_numerical': 0.02188411838265944, 'mean_word_length': 3.3946886446886446, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7242424', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1609, 'n_words': 352}