Skip to content

Commit

Permalink
minimal support for rk33xx
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Mar 1, 2019
1 parent 0f0fbe5 commit 6547a2a
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 12 deletions.
2 changes: 1 addition & 1 deletion eink-test/copyEPDControllers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TARGET_PATH="src/org/koreader/test/eink"

# Rockchip EPD Controllers
ROCKCHIP_PATH="${BASE_PATH}/rockchip"
ROCKCHIP_EPD="RK30xxEPDController"
ROCKCHIP_EPD="RK30xxEPDController RK33xxEPDController"

for EPD in ${ROCKCHIP_EPD}; do
src="${ROCKCHIP_PATH}/${EPD}.java"
Expand Down
25 changes: 21 additions & 4 deletions eink-test/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,42 @@
android:layout_height="12dp" />

<TextView
android:id="@+id/rockchipText"
android:id="@+id/rk30xxText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="22sp" />

<Button
android:id="@+id/rockchipNormalButton"
android:id="@+id/rk30xxNormalButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="rk30xx normal update"
android:textSize="28sp" />

<Button
android:id="@+id/rockchipForcedButton"
android:id="@+id/rk30xxForcedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="rk30xx forced update"
android:textSize="28sp" />


<TextView
android:layout_width="fill_parent"
android:layout_height="12dp" />

<TextView
android:id="@+id/rk33xxText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="22sp" />

<Button
android:id="@+id/rk33xxNormalButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="rk33xx normal update"
android:textSize="28sp" />
</LinearLayout>
</ScrollView>
43 changes: 37 additions & 6 deletions eink-test/src/org/koreader/test/eink/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MainActivity extends android.app.Activity {

private static final int RK30xxNORMAL = 1;
private static final int RK30xxFORCED = 2;
private static final int RK33xxNORMAL = 3;
private static final int FAKE = 999;

private static final String MANUFACTURER = android.os.Build.MANUFACTURER;
Expand All @@ -26,18 +27,21 @@ public void onCreate(android.os.Bundle savedInstanceState) {

TextView overview = (TextView) findViewById(R.id.overview);
TextView fakeDesc = (TextView) findViewById(R.id.fakeText);
TextView rockchipDesc = (TextView) findViewById(R.id.rockchipText);
TextView rk30xx_description = (TextView) findViewById(R.id.rk30xxText);
TextView rk33xx_description = (TextView) findViewById(R.id.rk33xxText);

Button fake_button = (Button) findViewById(R.id.fakeButton);
Button rk30xx_normal_button = (Button) findViewById(R.id.rockchipNormalButton);
Button rk30xx_forced_button = (Button) findViewById(R.id.rockchipForcedButton);
Button rk30xx_normal_button = (Button) findViewById(R.id.rk30xxNormalButton);
Button rk30xx_forced_button = (Button) findViewById(R.id.rk30xxForcedButton);
Button rk33xx_normal_button = (Button) findViewById(R.id.rk33xxNormalButton);

/** current device overview */
overview.setText("Manufacturer: " + MANUFACTURER);
overview.append("\n Brand: " + BRAND);
overview.append("\n Model: " + MODEL);
overview.append("\n Product: " + PRODUCT);
overview.append("\n Hardware: " + HARDWARE);
overview.append("\n Platform: " + getBuildProperty("ro.board.platform"));

/** fake eink */
fakeDesc.setText("This button does nothing! It's just an example of an empty action. ");
Expand All @@ -51,9 +55,9 @@ public void onClick(View view) {
}
});

/** rockchip */
rockchipDesc.setText("These buttons should invoke a full refresh of rockchip rk30xx devices. ");
rockchipDesc.append("Both normal and forced modes should work.");
/** rockchip rk30xx */
rk30xx_description.setText("These buttons should invoke a full refresh of rockchip rk30xx devices. ");
rk30xx_description.append("Both normal and forced modes should work.");

rk30xx_normal_button.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -67,6 +71,18 @@ public void onClick(View view) {
runEinkTest(RK30xxFORCED);
}
});

/** rockchip rk33xx */
rk33xx_description.setText("This button should work on boyue rk3368 clones.");

rk33xx_normal_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
runEinkTest(RK33xxNORMAL);
}
});


}

private void runEinkTest(int test) {
Expand All @@ -78,6 +94,9 @@ private void runEinkTest(int test) {
} else if (test == RK30xxFORCED) {
Log.i(TAG, "rockchip forced update");
RK30xxEPDController.requestEpdMode(v, "EPD_FULL", true);
} else if (test == RK33xxNORMAL) {
Log.i(TAG, "rockchip 33xx normal update");
RK33xxEPDController.requestEpdMode();
} else if (test == FAKE) {
Log.i(TAG, "fake update");
} else {
Expand All @@ -87,5 +106,17 @@ private void runEinkTest(int test) {
Log.e(TAG, e.toString());
}
}

private String getBuildProperty(String key) {
String value;
try {
value = (String) Class.forName("android.os.SystemProperties").getMethod(
"get", String.class).invoke(null, key);
} catch (Exception e) {
Log.e(TAG, e.toString());
value = "unknown";
}
return value;
}
}

9 changes: 8 additions & 1 deletion src/org/koreader/device/DeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum Device {
EINK_BOYUE_T61,
EINK_BOYUE_T62,
EINK_BOYUE_T80S,
EINK_BOYUE_T103D,
EINK_ONYX_C67,
EINK_ENERGY,
EINK_INKBOOK,
Expand All @@ -38,6 +39,7 @@ public enum Device {
public static final boolean EINK_BOYUE_T61;
public static final boolean EINK_BOYUE_T62;
public static final boolean EINK_BOYUE_T80S;
public static final boolean EINK_BOYUE_T103D;
public static final boolean EINK_ONYX_C67;
public static final boolean EINK_ENERGY;
public static final boolean EINK_INKBOOK;
Expand Down Expand Up @@ -71,6 +73,11 @@ public enum Device {
&& PRODUCT.toLowerCase().contentEquals("t80s");
deviceMap.put(Device.EINK_BOYUE_T80S, EINK_BOYUE_T80S);

// Boyue Likebook Mimas
EINK_BOYUE_T103D = (MANUFACTURER.toLowerCase().contentEquals("boeye") || MANUFACTURER.toLowerCase().contentEquals("boyue"))
&& PRODUCT.toLowerCase().contentEquals("t103d");
deviceMap.put(Device.EINK_BOYUE_T103D, EINK_BOYUE_T103D);

// Onyx C67
EINK_ONYX_C67 = MANUFACTURER.toLowerCase().contentEquals("onyx")
&& ( PRODUCT.toLowerCase().startsWith("c67") || MODEL.contentEquals("rk30sdk") )
Expand All @@ -92,7 +99,7 @@ public enum Device {


// true if we found a supported device
IS_EINK_SUPPORTED = (EINK_BOYUE_T62 || EINK_BOYUE_T61 || EINK_BOYUE_T80S || EINK_ONYX_C67 || EINK_ENERGY || EINK_INKBOOK);
IS_EINK_SUPPORTED = (EINK_BOYUE_T62 || EINK_BOYUE_T61 || EINK_BOYUE_T80S || EINK_BOYUE_T103D || EINK_ONYX_C67 || EINK_ENERGY || EINK_INKBOOK);

// find current device.
Iterator<Device> iter = deviceMap.keySet().iterator();
Expand Down
6 changes: 6 additions & 0 deletions src/org/koreader/device/EPDFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.koreader.device.rockchip.RK3026EPDController;
import org.koreader.device.rockchip.RK3066EPDController;
import org.koreader.device.rockchip.RK3368EPDController;


public class EPDFactory {
Expand All @@ -31,6 +32,11 @@ public static EPDController getEPDController() {
epdController = new RK3066EPDController();
break;

/** supported rk3368 devices */
case EINK_BOYUE_T103D:
epdController = new RK3368EPDController();
break;

/** unsupported devices */
case UNKNOWN:
epdController = new FakeEPDController();
Expand Down
16 changes: 16 additions & 0 deletions src/org/koreader/device/rockchip/RK3368EPDController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** RK3368, tested on a Boyue Likebook Mimas */

package org.koreader.device.rockchip;

import android.view.View;

import org.koreader.device.EPDController;

/** we don't care about view on this driver */
@SuppressWarnings("unused")
public class RK3368EPDController extends RK33xxEPDController implements EPDController {
@Override
public void setEpdMode(View targetView, String epdMode) {
requestEpdMode(epdMode);
}
}
45 changes: 45 additions & 0 deletions src/org/koreader/device/rockchip/RK33xxEPDController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* minimal rk33xx interface for boyue mimas and maybe others,
* based on https://github.com/koreader/koreader/issues/4595
*
*/

package org.koreader.device.rockchip;

import android.util.Log;


@SuppressWarnings("unchecked")
public abstract class RK33xxEPDController {
private static final String TAG = "luajit-launcher";
public static final int EPD_FULL = 1;
public static final int EPD_A2 = 2;
public static final int EPD_PART = 3;
public static final int EPD_BLACK_WHITE = 6;
public static final int EPD_FORCE_FULL = 11;
public static final int EPD_REGAL = 15;
public static final int EPD_ADAPTATIVE = 17;
public static final int EPD_FAST = 18;
public static final int EPD_DITHER = 100;

public static boolean requestEpdMode(String epdMode) {
try {
Class.forName("android.view.View").getMethod("setByEinkUpdateMode",
new Class[] { Integer.TYPE }).invoke(null, new Object[] { getEpdMode(epdMode) });
return true;
} catch (Exception e) {
Log.e(TAG, e.toString());
return false;
}
}

private static int getEpdMode(String epdMode) {
/** only full mode was tested, so return that.
* device owners will want to expand this
* to return other well known modes
*/
int mode = EPD_FULL;
Log.v(TAG, String.format("Requesting %s: %d", epdMode, mode));
return mode;
}
}

0 comments on commit 6547a2a

Please sign in to comment.