Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Calculations/haskell/solarduino-haskell/.idea/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion Calculations/haskell/solarduino-haskell/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import TimeConverters

--main :: IO ()
--main = print (directPower 10 0.5)
main = writeBestAnglesToFile "angles.times" (fromGregorian 2019 8 13) (fromGregorian 2019 8 20) 10000 100
main = writeBestAnglesToFile "angles.times" (fromGregorian 2019 8 15) (fromGregorian 2019 8 15) 10000 100
---- | Benchmark functions using Criterion.
--main = defaultMain [
-- bgroup "benchmarking..." [ -- would usually be function name here
Expand Down
3 changes: 3 additions & 0 deletions SolAppduino/SolArduino/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ dependencies {

// Bottom App Bar
implementation 'com.android.support:design:28.0.0'

// Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.abbyberkers.solarduino
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.abbyberkers.solarduino.ui.HomeFragment
import com.abbyberkers.solarduino.ui.ScheduleFragment
import com.abbyberkers.solarduino.ui.schedule.ScheduleFragment
import com.abbyberkers.solarduino.ui.replace
import kotlinx.android.synthetic.main.activity_main.*

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.abbyberkers.solarduino.ui.schedule

import com.github.mikephil.charting.components.AxisBase
import com.github.mikephil.charting.formatter.ValueFormatter
import java.text.SimpleDateFormat
import java.util.*

/**
* Formatter for axis values.
*/
class AxisTimeFormatter : ValueFormatter() {
/**
* Formats a value given in seconds since 01-01-1970 as HH:mm.
*/
override fun getAxisLabel(value: Float, axis: AxisBase?): String {
val format = SimpleDateFormat("HH:mm", Locale.getDefault())
return format.format(value * 1000)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.abbyberkers.solarduino.ui.schedule

import android.content.Context
import com.abbyberkers.solarduino.R
import com.github.mikephil.charting.charts.LineChart
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet

/**
* A chart with the schedule for today's angles.
*/
class ScheduleChart(private val data: List<SchedulePoint>,
private val chart: LineChart,
private val context: Context) {

init {
val entries = this.data.map { Entry(it.time, it.angle) }
val dataSet = LineDataSet(entries, "label")
// Style the chart with the apps colors.
dataSet.apply {
color = context.getColor(R.color.colorAccent)
setCircleColor(context.getColor(R.color.colorAccent))
}
val lineData = LineData(dataSet)

this.chart.apply {
data = lineData
description.isEnabled = false
legend.isEnabled = false
xAxis.valueFormatter = AxisTimeFormatter()
invalidate() // Refresh the chart.
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.abbyberkers.solarduino.ui.schedule

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.abbyberkers.solarduino.R

class ScheduleFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.schedule_fragment, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
ScheduleChart(getChartData(), view.findViewById(R.id.schedule_chart), context!!)
}

/**
* TODO get the data from the Pi instead of our own little file located in /res/raw.
* TODO move to PanelRequestSender?
*
* Gets the data for the schedule chart.
*/
private fun getChartData(): List<SchedulePoint> {
val rawId = resources.getIdentifier("angles", "raw", "com.abbyberkers.solarduino")
return resources.openRawResource(rawId).bufferedReader().useLines { lines ->
lines.map {
val angleTime = it.split(" ")
SchedulePoint(angle = angleTime.first().toFloat(),
time = angleTime.last().toFloat())
}.toList()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.abbyberkers.solarduino.ui.schedule

data class SchedulePoint(val angle: Float, val time: Float)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:padding="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/floop"
android:text="hallo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/schedule_chart"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</LinearLayout>
4 changes: 2 additions & 2 deletions SolAppduino/SolArduino/app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:id="@+id/home_button"
android:enabled="true"
android:icon="@drawable/ic_home"
android:title="Home"
android:title="@string/home"
app:showAsAction="always" />

<item
Expand All @@ -21,6 +21,6 @@
android:id="@+id/schedule_button"
android:enabled="true"
android:icon="@drawable/ic_schedule"
android:title="Plaatje"
android:title="@string/schedule"
app:showAsAction="always" />
</menu>
100 changes: 100 additions & 0 deletions SolAppduino/SolArduino/app/src/main/res/raw/angles.times
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
0.0 1565843217.6
33.1076996727392 1565843744.7
42.94448583661988 1565844271.9
46.05020230051852 1565844799.1
47.60489906817322 1565845326.2
48.46266986812638 1565845853.4
48.94012277717066 1565846380.6
49.190748484736126 1565846907.8
49.30713689873636 1565847434.9
49.33233992112289 1565847962.1
49.29751020080393 1565848489.3
49.210001880600984 1565849016.4
49.09361346660076 1565849543.6
48.94607240369233 1565850070.8
48.782955016329794 1565850597.9
48.60058423310239 1565851125.1
48.39668749889922 1565851652.3
48.189113693285286 1565852179.5
47.965963563217265 1565852706.6
47.72723710869512 1565853233.8
47.48256102765132 1565853761
47.23420787519676 1565854288.1
46.970278398288094 1565854815.3
46.70039929485775 1565855342.5
46.42089349349499 1565855869.6
46.13543806561055 1565856396.8
45.84035593979368 1565856924
45.53564711604438 1565857451.2
45.221311594362646 1565857978.3
44.90102644615926 1565858505.5
44.57111460002343 1565859032.7
44.23525312736592 1565859559.8
43.88381533025432 1565860087
43.52502339032119 1565860614.2
43.158009268755485 1565861141.4
42.77174175132491 1565861668.5
42.381797162483586 1565862195.7
41.97400369407725 1565862722.9
41.556583527738475 1565863250
41.125859592056514 1565863777.2
40.677286776809545 1565864304.4
40.21541019221937 1565864831.5
39.73428021176435 1565865358.7
39.23530135174431 1565865885.9
38.717069095859415 1565866413.1
38.18326051552041 1565866940.2
37.624248912794876 1565867467.4
37.0400342876828 1565867994.6
36.430616640184205 1565868521.7
35.79599597029908 1565869048.9
35.13389972291649 1565869576.1
34.43924631032587 1565870103.2
33.70749062230538 1565870630.4
32.938632658855 1565871157.6
32.137217530196565 1565871684.8
31.283123801654163 1565872211.9
30.388250726271128 1565872739.1
29.437021979593357 1565873266.3
28.437659743253423 1565873793.4
27.370042582575426 1565874320.6
26.23644305267025 1565874847.8
25.03318408212715 1565875375
23.746093862791877 1565875902.1
22.373767878364575 1565876429.3
20.90657943091281 1565876956.5
19.330356712282338 1565877483.6
17.643695206173298 1565878010.8
15.825068961609935 1565878538
13.868528352070564 1565879065.1
11.75849705310109 1565879592.3
9.481671295358318 1565880119.5
7.0224747543881465 1565880646.7
4.371280732258147 1565881173.8
1.5102403494033085 1565881701
0.0 1565882228.2
0.0 1565882755.3
0.0 1565883282.5
0.0 1565883809.7
0.0 1565884336.8
0.0 1565884864
0.0 1565885391.2
0.0 1565885918.4
0.0 1565886445.5
0.0 1565886972.7
0.0 1565887499.9
0.0 1565888027
0.0 1565888554.2
0.0 1565889081.4
0.0 1565889608.6
0.0 1565890135.7
0.0 1565890662.9
0.0 1565891190.1
0.0 1565891717.2
0.0 1565892244.4
0.0 1565892771.6
0.0 1565893298.7
0.0 1565893825.9
0.0 1565894353.1
0.0 1565894880.3
0.0 1565895407.4
2 changes: 2 additions & 0 deletions SolAppduino/SolArduino/app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
<string name="downbuttondescription">Knop omlaag</string>
<string name="upbuttondescription">Knop omhoog</string>
<string name="setanglebutton">Draai panelen</string>
<string name="home">Thuis</string>
<string name="schedule">Planning</string>
</resources>
4 changes: 3 additions & 1 deletion SolAppduino/SolArduino/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<string name="initialdegrees">42°</string>
<string name="imagepaneldescription">Solar Panel</string>
<string name="setanglebutton">Set angle</string>
<string name="update">Check for updates</string>
<string name="update" translatable="false">Check for updates</string>
<string name="home">Home</string>
<string name="schedule">Schedule</string>
</resources>
4 changes: 2 additions & 2 deletions SolAppduino/SolArduino/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
repositories {
google()
jcenter()

maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
Expand All @@ -28,7 +28,7 @@ allprojects {
repositories {
google()
jcenter()

maven { url 'https://jitpack.io' }
}
}

Expand Down